TextBox disable status is not preserved by asp.net

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

Hi,

I found out that Text property is perserved, but disable/enable status is
not preserved, especially I change this setting of a server side text box
with client side javascipt and then post back to server.

Is this a bug?
Thanks,
 
not really, its a limitation. the client only posts back the value and if
using viewstate, the original attribute values. if you need to know changes,
then you must store the attributes in a hidden field.

note: if you disable a textbox in javascript, it will not postback its value
(as the browser does not post disabled fields).


-- bruce (sqlwork.com)
 
Thanks both Bruce and Patrice.

Besides hidden field, is there other better way to transmite changed
property by client scipt back to server, e.g. manually adjust view state in
client before post back? That is how to narrow the seperation between server
and client?

Thanks!
Ryan
 
Thanks both Bruce and Patrice.

Besides hidden field, is there other better way to transmite changed
property by client scipt back to server, e.g. manually adjust view state in
client before post back?  That is how to narrow the seperation between server
and client?

Thanks!
Ryan






- Show quoted text -

you can do your own post back, e.g:
let's say youy have a button to submit a form with onclientclick =
"do_form_submit();":
<script>
function do_form_submit()
{
var value_to_submit = document.getElementById("textBox").value;
value_to_submit = value_to_submit + "|" +
document.getElementById("textBox").disabled;

__doPostBack( "form_post_back", value_to_submit);
}
</script>

then, on server -side, something like this (in vb.net):
sub Page_Load(...)

if Page.Request.Params.Get ("__EVENTTARGET") = "form_post_back" then
dim valuePostBackValue as string = Page.Request.Params.Get
("__EVENTARGUMENT")
dim textValue = valuePostBackValue.Split("|")(0)
dim textBoxDisabledValue = valuePostBackValue.Split("|")(1)
end if


.... more at http://www.siccolo.com/articles.asp ...
end sub
 
Thanks Siccolo.

Then I guess no other data will be in this post, e.g. values in other html
input fields will not be sent to server, right?

Thanks,
 
Back
Top