I have doubt regarding MasterPages & Content Pages...
-
Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.
-
Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.
Can you use validation controls, for validations.
-
Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.
Hi, there is a property for each control called ClientID (see here http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx[^]). Use this property while generating the javascript, so that the controls can be accessed by this property. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Hi, there is a property for each control called ClientID (see here http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx[^]). Use this property while generating the javascript, so that the controls can be accessed by this property. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
Thank you SeMartens for your immediate response,I would be more useful. If you provide a simple sample about how to access the controls in client side.
-
Thank you SeMartens for your immediate response,I would be more useful. If you provide a simple sample about how to access the controls in client side.
How do you attach the validation to the controls? If you have sth like a client-side event attached to the controls you can do sth like this: ASP-Code
myTextbox.Attributes("onclick", "javascript:validateTextbox('" + myTextbox.ClientID + "')");
and the javascript will look like this:
validateTextbox(clientID) {
var control = document.getElementByID(clientID);
// do sth with the control -> validate etc.
}It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.
you can either read it this way document.getElementById("<%=Button1.ClientID%>") or set the master page id in page load of master page like this this.ID = "MyID"; then your control id will be MyID_contentplaceholderid_controlid also keep in mind that clientid wont work in js files
-
Hai, I am using Master Pages and content Pages to design my website. Inside the content Page i have Form with textboxes. To validate the text boxes in client side, I am using Jscript. But when controls are placed inside the content page the Id of the controls are changed as follows "txtPwd" to "ctl00_CPH_txtPwd".Due to this i can't able to access the controls in client side. I am inneed of an immediate solution to solve this problem. Can you help me in solving this issue.Thanks in advance.
Use document.getElementById ("<%=TextBox1.ClientId%>").value