So, after working with .NET for
so long, it has finally caught me out and thrust me into “Config Hell”.
I’ve been having a problem of my
dropdownlists not persisting data when I dynamically populate them at
run-time. I could populate and
select an option, but when the page did a post-back, not only was there no
selected value, but the dropdownlist was empty.
I couldn’t figure out what was
wrong. I knew it had to be the
viewstate, but I couldn’t figure out where I had turned it off. After 2 days of battling I gave up and
went home to enjoy the weekend.
Sunday saw me sleeping in, and
stressing about how to work around this problem. Eventually I had an idea. I remembered reading somewhere that the
sessionstate of CRM was off by default (for security reasons); I wondered if it
was possible that the viewstate was off by default too. Excitedly, I hurried to the office and
searched the CRM config files.
I quickly found what I was
looking for. In the web.config file
in the root of the CRM website is a <pages> tag
with the attribute enableViewState and it was set to
false! Suddenly, after changing it,
my dropdownlists were persisting data.
So, you have been
warned!
What stumped me earlier was that
I was dynamically populating listboxes in dialog windows and they were working
perfectly. But, in truth, I was
never doing a post-back; I was reading the selected value on the
client-side.
There is one question for the CRM
team though. How is the CRM website
affected by the <pages> tag?
I can’t believe that they’re not making use of sessionstates and
viewstates.
powered by IMHO 1.2