asp.net - Viewstate Disabled - Dropdown box not returning values -


in effort speed site, trying disable viewstate don't think using everywhere. have master page setup user controls loaded (using loadcontrol) in default.aspx. typical page setup be:

main.master -> default.aspx -> controlwrapper.ascx -> mycontrol.ascx

i have put enableviewstate="false" in default.aspx page. when try , read value dropdownlist in mycontrol.ascx comes blank when form posted. first all, why this? thought should still able read value drop down list?

i tried enabling viewstate on control , didn't work.

i tried enabling viewstate on page_init event of mycontrol.ascx using page.enableviewstate = true; didn't either.

i guess misunderstanding viewstate somewhat, can point me in right direction please?

p.s don't know if information relevant adding contents of dropdownlist dynamically in page_load event. (thinking it, issues - test now).

thanks.

i assume you're using .net 4. view state method asp.net page framework uses preserve page , control values between round trips.

the reason didn't work when view state turned off because control rendered again when performed postback server, meaning lost selected value.

the reason didn't work when view state off page, on control because in order work, following conditions must met:

  • the enableviewstate property page set true.
  • the enableviewstate property control set true.
  • the viewstatemode property control set enabled or inherits enabled setting.

asp .net view state overview


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -