3+ basic questions for asp:RadioButton, related to ViewState, life cycle, javascript

R

Ryan Liu

Just curious, why, for instance

<asp:RadioButton runat="server"> or <intput type="radio" runat="server"
disabled="disabled"> will not post "Checked" state back if initially they
are disabled, either disabled in code behind or mark up.

I mointor http post string, actually the information is available.

Also <asp:Button> 's Text property is also not post back if I changed it on
client side using javascript.

================
This leads me think about a more general question, for a user input control,
in asp.net life cycle,
when does it assign the server control's property with (old) value found in
view state, and
when does the same property be assigned with new value in Request.Params
(user type in input), and overwrite property value got from view state,
and I assume then update viewstate with new values from user input?

I read MSDN online, it only mention load viewstate and control state, does
not mention when to load user input.

And on server side, does it treat user type in input same as the value
modified by client javascript? But of couse, view state will not be modified
by javascript.

And can someone point out a link list the properties been preserved in
viewstate. Seems Button.Text is not.

And viewstate will be always build and modified on server side, right? It
never happens on client side (except hacker).

===============
Another issue is ASP.NET render <asp:RadioButton> in a <span
disabled="disabled"> <input type=radio disabled="disabled"> </span>, this
is problematic in IE for javascript. First disabled is not a vlid property
for span, second, when I write javascript to enable radio button, I have to
remvoe "disable" attr of <span> as well. -- Why Microsoft does that?



Thanks a lot!
Ryan
 
B

bruce barker

the browser does not postback disabled fields. also it only posts back
the name and value of <input>, <select> and <textarea> elements inside
of the posting form. in the case of input type checkbox and radio, only
the value of a selected one is posted back.

you can use hidden fields to post back addition info via client script.

-- bruce (sqlwork.com)
 
B

bruce barker

addendum:

most controls (if they follow the ms pattern), store all properties in
viewstate (this is why its so big, and shoudl be disabled in most cases).

a control has a life cycle, if your control accepts user input a
loaddata event. loaddata happens between oninit and onload. load of
viewstate happen between oninit and loaddata.

-- bruce (sqlwork.com)
 
R

Ryan Liu

Thanks! Initilally I disalbed the control, but I alreay enabled them in
browser by javascript and I see data in http post stream.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top