TextBox disable status is not preserved by asp.net

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,
 
B

bruce barker

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)
 
R

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
 
S

siccolo

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
 
R

Ryan

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,
 

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

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top