Connecting Tech Pros Worldwide Help | Site Map

Checkbox with javascript change - old value in code behind

Marc Castrechini
Guest
 
Posts: n/a
#1: Nov 18 '05
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


Marc Castrechini
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Checkbox with javascript change - old value in code behind


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:eXtrv9TWEHA.716@TK2MSFTNGP11.phx.gbl...[color=blue]
> 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[/color]
the[color=blue]
> 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
>
>[/color]


Patrice
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Checkbox with javascript change - old value in code behind


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:%230L9lDUWEHA.2408@tk2msftngp13.phx.gbl...[color=blue]
> 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[/color]
stop.[color=blue]
>
> 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:eXtrv9TWEHA.716@TK2MSFTNGP11.phx.gbl...[color=green]
> > I have a page that changes an <ASP:Checkbox value based on a user[/color][/color]
entered[color=blue][color=green]
> > value in a textboxm using client side Javascript.
> >
> > After my submit is fired the value for the chkMyCB.checked does not get[/color]
> the[color=green]
> > latest value of the checkbox.
> >
> > Does this sound like a posibility and if so how can I force the server[/color][/color]
to[color=blue][color=green]
> > get the new value from the page?
> >
> > TIA,
> > - Marc Castrechini
> >
> >[/color]
>
>[/color]


Marc Castrechini
Guest
 
Posts: n/a
#4: Nov 18 '05

re: Checkbox with javascript change - old value in code behind


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" <nobody@nowhere.com> wrote in message
news:uE05kJUWEHA.1656@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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[/color]
try[color=blue]
> 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[/color]
de[color=blue]
> news:%230L9lDUWEHA.2408@tk2msftngp13.phx.gbl...[color=green]
> > 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[/color]
> stop.[color=green]
> >
> > 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[/color][/color]
chkMyCB.checked[color=blue][color=green]
> > value.
> >
> > TIA,
> > - Marc Castrechini
> >
> > "Marc Castrechini" <mc@merchantwareh4o3u2s1e.com> wrote in message
> > news:eXtrv9TWEHA.716@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > I have a page that changes an <ASP:Checkbox value based on a user[/color][/color]
> entered[color=green][color=darkred]
> > > value in a textboxm using client side Javascript.
> > >
> > > After my submit is fired the value for the chkMyCB.checked does not[/color][/color][/color]
get[color=blue][color=green]
> > the[color=darkred]
> > > latest value of the checkbox.
> > >
> > > Does this sound like a posibility and if so how can I force the server[/color][/color]
> to[color=green][color=darkred]
> > > get the new value from the page?
> > >
> > > TIA,
> > > - Marc Castrechini
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread