By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,009 Members | 2,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,009 IT Pros & Developers. It's quick & easy.

Checkbox with javascript change - old value in code behind

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

"Marc Castrechini" <mc@merchantwareh4o3u2s1e.com> wrote in message
news:eX*************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

P: n/a
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 ?
--

"Marc Castrechini" <mc@merchantwareh4o3u2s1e.com> a écrit dans le message de
news:%2****************@tk2msftngp13.phx.gbl...
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

"Marc Castrechini" <mc@merchantwareh4o3u2s1e.com> wrote in message
news:eX*************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3

P: n/a
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

"Patrice" <no****@nowhere.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
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 ?
--

"Marc Castrechini" <mc@merchantwareh4o3u2s1e.com> a écrit dans le message de news:%2****************@tk2msftngp13.phx.gbl...
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

"Marc Castrechini" <mc@merchantwareh4o3u2s1e.com> wrote in message
news:eX*************@TK2MSFTNGP11.phx.gbl...
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



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.