textbod id changed automatically

  • Thread starter Thread starter Ganesh
  • Start date Start date
G

Ganesh

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
 
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( said:
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/transla...&hl=de&ie=UTF-8&oe=UTF-8&prev=/language_tools
 
Hi Peter,

Thanks for your help.


Peter Bucher said:
Hello Ganesh


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/transla...&hl=de&ie=UTF-8&oe=UTF-8&prev=/language_tools

--
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
 
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.
 
Back
Top