GibbsUSA.net Blogs  

Sunday, February 05, 2012

 Logon   Back to Blog   Blogs Home   GibbsUSA.net Home  


Archives
 Home... 
 May 2008 (1) 
 August 2007 (2) 
 December 2006 (1) 
 October 2006 (5) 
 

Leave your comments...

8/15/2007 8:23 AM: Client JavaScript and .NET Server Controls

GibbsUSA.net smilie: grim The new .NET model renames the server controls dynamically, giving them a unique ID. See below for an example.

The following is the control on the ASPX page designer:
<asp:CheckBox id=chkBInfo runat=server checked=true/>

This is rendered to the client in HTML as:
<input id="ctl00_ContentPlaceHolder1_chkBInfo" type="checkbox" name="ctl00$ContentPlaceHolder1$chkBInfo" checked="checked" />

As you can see, the controls name cannot be determined easily...or can it???

Well, so long as your JavaScript remains on the same ASPX page, you can get the control using "ClientID":
function theForm_onSubmit(){
if (document.forms(0).<%=chkBInfo.ClientID%>.checked==false)
{
alert('Please select a Message Type...');
return false;
}
}

Hope this helps!!! GibbsUSA.net smilie: coolguy
Print >>> EMail >>>

Comments:
Please log on to the GibbsUSA site to post comments...

 

Join Chris on Facebook 
CLR v2.0.50727.3625


Please see the site Terms And Conditions and the site Privacy Statement.
This entire web site (and the software contents therein) is Copyright © Chris Gibbs 2000-2012.
Any reproduction or copying is expressly forbidden without the prior consent of Chris Gibbs.
For more information, please contact the site WebMaster (WebMaster@GibbsUSA.net).