Checkbox with javascript change - old value in code behind

M

Marc Castrechini

I have a page that changes an <ASP:Checkbox value based on a user entered
value in a textboxm using client side Javascript.

After my submit is fired the value for the chkMyCB.checked does not get the
latest value of the checkbox.

Does this sound like a posibility and if so how can I force the server to
get the new value from the page?

TIA,
- Marc Castrechini
 
M

Marc Castrechini

More:
I just realized that I have the checkbox disabled because the user isn't
allowed to change the checked value manually and I don't want the tab stop.

I see now that if the control is enabled the value returns properly.
Javascript allows the value to change even if the control is disabled.

Does anyone know how I can keep the control disabled but get a current
checked value from it? Later in the code I am using that chkMyCB.checked
value.

TIA,
- Marc Castrechini
 
P

Patrice

When you submit a form, the value for the disabled HTML controls are not
posted back to the server.

- You could use an hidden field.
- Or if the user is not allowed to change this (even indirectly), don't try
to update this value but read the original value server side (you knwo the
user can't have changed this value ?)
- Or reenable the field client side just before submitting (probably bad
visually unless you display a please wait message while processing the
values).
- Others ?


--
 
M

Marc Castrechini

Thanks for the help. The hidden field idea got me to thinking about using
more Javascript. It will work nicely for me to have the checkbox "appear"
disabled by changing this.checked when they click and disable the tab stop
in ASP.NET

Modified from something found on the web:
Public Sub MakeReadOnly(ByRef CheckBox As CheckBox)

CheckBox.Attributes.Add("onClick", "this.checked=!this.checked;")

CheckBox.TabIndex = -1

End Sub


Web link for source:
http://www.mcse.ms/archive110-2004-6-659756.html

Thanks again,
- Marc
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top