Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

textbod id changed automatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ganesh - 29 Jul 2007 16:27 GMT
Hi There,

I've a master page, and the content place i'v a page which has a text box
name tbCity. I would like to use javascript to find out that was blank or
not.

When i look at the sourcecode th text box id was chagned to
ctl00_Main_tbCity

why is it like this.

Thanks
Peter Bucher [MVP] - 29 Jul 2007 17:21 GMT
Hello Ganesh

> I've a master page, and the content place i'v a page which has a text box
> name tbCity. I would like to use javascript to find out that was blank or
> not.
document.getElementById(<Control.ClientID>).value == '';

> When i look at the sourcecode th text box id was chagned to
> ctl00_Main_tbCity
>
> why is it like this.
On the server side, ASP.NET has features like, nesting Controls, Namespaces,
etc..
that help to have consistente IDs. That means also, you can have more then
on of the same IDs on a page.
When ASP.NET rendered the code for viewing in a Html Browser, there are no
features like on the server side.
Here you can`t have more then one identic ID for a control.
So ASP.NET generates automatically IDs and Names where based on the control
hierarchy.
The <Control>.ClientID represents the ID Attribute on the clientside.
The <Control>.UniqueID represents the NAME Attribute on the clientside.

I have written a german article about identification of ASP.NET Controls.
Maybe you`r be able to understand the Google Translated Page:
-
http://translate.google.com/translate?u=http%3A%2F%2Fwww.aspnetzone.de/blogs/pet
erbucher/archive/2007/04/09/artikel-identifizierung-von-controls-control-id-clie
ntid-uniqueid.aspx&langpair=de%7Cen&hl=de&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_too
ls


Signature

Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

Ganesh - 29 Jul 2007 17:31 GMT
Hi Peter,

Thanks for your help.

> Hello Ganesh
>
[quoted text clipped - 23 lines]
> -
> http://translate.google.com/translate?u=http%3A%2F%2Fwww.aspnetzone.de/blogs/pet
erbucher/archive/2007/04/09/artikel-identifizierung-von-controls-control-id-clie
ntid-uniqueid.aspx&langpair=de%7Cen&hl=de&ie=UTF-8&oe=UTF-8&prev=%2Flanguage_too
ls
Mark Rae [MVP] - 29 Jul 2007 17:38 GMT
> I've a master page, and the content place i'v a page which has a text box
> name tbCity. I would like to use javascript to find out that was blank or
> not.
>
> When i look at the sourcecode th text box id was chagned to
> ctl00_Main_tbCity

if (document.getElementById(<%=tbCity.ClientID%>).value == '')
{
   // do something
}

> why is it like this.

To guarantee uniqueness of ID.

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.