开发者

Server side disabled input radio not preserving client changed state on postback

开发者 https://www.devze.com 2023-01-10 04:58 出处:网络
This is a strange one that has been bugging me today. Due to the fact that asp:RadioButtons get rendered in a span I decided to use a std input control with runat=\"server\".

This is a strange one that has been bugging me today. Due to the fact that asp:RadioButtons get rendered in a span I decided to use a std input control with runat="server".

<input ID="rbDayRate" type="radio" runat="server" disabled="disabled" />

Now as you can see by default this control is disabled. It is enabled by jQuery if the user clicks on a checkbox. However once the state of the control gets to the serversi开发者_Go百科de and I come to use it is not the correct value.

I have checked for all code that is modifying it after the postback data has been loaded and there is none. I have even checked the http post data in Fiddler2 and it is correctly being sent back by the browser.

What's even stranger is if I remove the disabled flag the control works fine.

Any ideas what's going on?!?!


Richard,

Reason is, you have disabled the control from the server side, even if you enabled it from client using JQuery, SERVER DOES NOT KNOW ABOUT IT. Therefore it keeps the same value as it is not expecting to change the value of a disabled control...

Try to disable it onload from client, should work this way....


You can try adding enableviewstate="true" property to the control. That should allow the control to keep its data/values after postback.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号