MasterPages in .NET 2.0 and control naming
-
I've tried out the express version of Visual Web Developer in order to find out a few details on the new MasterPage framework in .NET 2.0. To my surprice, it found a little problem in the naming of servercontrols that I use in my contentpages. For example if I use a WebControls.Button, I declare it in the aspx file as: Now in regular cases, the control would render itself as an tag on the final document, having it's id parameter set to the id of the Button control. But when using the MasterPages all server controls that produce some sort of html-tag that would be interesting to manipulate on client-side gets an addition to their id. Like . And this produces some problem in some cases. I dont know if it's just because of .NET 2.0 being beta right now or if that's the way it should be in order for the framework to route the events to the right place on postbacks. I hope someone here can give me some more insight into this or point me in the right direction on this.
-
I've tried out the express version of Visual Web Developer in order to find out a few details on the new MasterPage framework in .NET 2.0. To my surprice, it found a little problem in the naming of servercontrols that I use in my contentpages. For example if I use a WebControls.Button, I declare it in the aspx file as: Now in regular cases, the control would render itself as an tag on the final document, having it's id parameter set to the id of the Button control. But when using the MasterPages all server controls that produce some sort of html-tag that would be interesting to manipulate on client-side gets an addition to their id. Like . And this produces some problem in some cases. I dont know if it's just because of .NET 2.0 being beta right now or if that's the way it should be in order for the framework to route the events to the right place on postbacks. I hope someone here can give me some more insight into this or point me in the right direction on this.
Hi there, I guess that you're not familiar with the ASP.NET 1.x, so you have no idea about the control identification. What you see when you view source at the client side is the value of the
ClientID
property of the control. Each control basically has 3 properties regarding to its ID that you may need to know:ID
,UniqueID
andClientID
. TheID
propety is the programmatic identifier of a control which you can enter in the Properties window, and you use this property to make a reference to the control to access its properties, methods... In reality, you can place a button with the IDbtnSubmit
on the content page and you can also place another button with the same ID on its master page. It means that you can place the controls with the same ID in different containers, however, every control on a web page must be uniquely identifiable. So theUniqueID
property is used to differentiate the controls, it basically includes the identifier of the container, but you will not use this property in code. TheClientID
property is automatically generated by the ASP.NET to identify a control at the client side, this property is much the same as the UniqueID with one exception is the delimitor (':
' for the UniqueID, '_
' for the ClientID). For more information, you can see these properties of the Control class[^] in MSDN, and Web Forms Control Identification[^] -
Hi there, I guess that you're not familiar with the ASP.NET 1.x, so you have no idea about the control identification. What you see when you view source at the client side is the value of the
ClientID
property of the control. Each control basically has 3 properties regarding to its ID that you may need to know:ID
,UniqueID
andClientID
. TheID
propety is the programmatic identifier of a control which you can enter in the Properties window, and you use this property to make a reference to the control to access its properties, methods... In reality, you can place a button with the IDbtnSubmit
on the content page and you can also place another button with the same ID on its master page. It means that you can place the controls with the same ID in different containers, however, every control on a web page must be uniquely identifiable. So theUniqueID
property is used to differentiate the controls, it basically includes the identifier of the container, but you will not use this property in code. TheClientID
property is automatically generated by the ASP.NET to identify a control at the client side, this property is much the same as the UniqueID with one exception is the delimitor (':
' for the UniqueID, '_
' for the ClientID). For more information, you can see these properties of the Control class[^] in MSDN, and Web Forms Control Identification[^]