Client Side Checkbox Code

G

Guest

I have a checkbox on a web page. When it is checked, I want a Table to appear (or disappear when the checkbox is cleared)... I was hoping to use client side code for this, so I created a short vbscript routine and added this to my code behind module:

chkRecur.Attributes.Add("onchange", "vbscript: ShowRecurringTable")

Now, this works just fine on a couple of textboxes that I'm using, but when I try this technique with the asp checkbox, the "onchange" attribute gets added to a <span> element before the <input> element when rendered...

Can someone explain why this is happening? Can someone explain a simple way to accomplish this with an ASP checkbox server control, without requiring a trip back to the server? Thanks.

Jerry
 
R

Remy

<Span> should not be an issue. Is it not working that way? I often add
my OnChange events into span blocks.

Remy
 
G

Guest

The code never runs when the checkbox is clicked... I ended up using the
server side event.
 
S

Steven Cheng[MSFT]

Hi Jerry,

The ASP.NET CheckBox control is a customized one compared to the raw html
<input type=checkbox....> element. So it use a <span> to wrapper the <input
type=checkbox> and a <label> (normal html checkbox dosn't have text
.......). Thus, all the serverside attributes we apply on the asp.net
checkbox control will appear in the <span> element..... As for this
problem, I used to use the "onclick" event instead since each time the
"onclick" event occur, the checkbox's <span> will also notify its child
element and cause the <input checkbox> also change status.... You can have
a try on this to see whether it helps.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: Client Side Checkbox Code
| Date: Fri, 16 Dec 2005 16:32:45 -0500
| Lines: 12
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 198.160.134.100
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365409
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| The code never runs when the checkbox is clicked... I ended up using the
| server side event.
|
| | > <Span> should not be an issue. Is it not working that way? I often add
| > my OnChange events into span blocks.
| >
| > Remy
| >
|
|
|
 
S

Steven Cheng[MSFT]

Hi Jerry,

Does the suggestion in my last reply helps you a little, if there're
anything else we can help, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| X-Tomcat-ID: 51533511
| References: <[email protected]>
<[email protected]>
<[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Mon, 19 Dec 2005 03:21:47 GMT
| Subject: Re: Client Side Checkbox Code
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 50
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:365623
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Jerry,
|
| The ASP.NET CheckBox control is a customized one compared to the raw html

| <input type=checkbox....> element. So it use a <span> to wrapper the
<input
| type=checkbox> and a <label> (normal html checkbox dosn't have text
| ......). Thus, all the serverside attributes we apply on the asp.net
| checkbox control will appear in the <span> element..... As for this
| problem, I used to use the "onclick" event instead since each time the
| "onclick" event occur, the checkbox's <span> will also notify its child
| element and cause the <input checkbox> also change status.... You can
have
| a try on this to see whether it helps.
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
| --------------------
| | From: <[email protected]>
| | References: <[email protected]>
| <[email protected]>
| | Subject: Re: Client Side Checkbox Code
| | Date: Fri, 16 Dec 2005 16:32:45 -0500
| | Lines: 12
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| | Message-ID: <[email protected]>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet
| | NNTP-Posting-Host: 198.160.134.100
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet:365409
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | The code never runs when the checkbox is clicked... I ended up using
the
| | server side event.
| |
| | | | > <Span> should not be an issue. Is it not working that way? I often add
| | > my OnChange events into span blocks.
| | >
| | > Remy
| | >
| |
| |
| |
|
|
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top