Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to validate a user control in ASPX page

, 13 Jun 2011
Rate this:
Please Sign up or sign in to vote.
How to validate a user control in ASPX page
It's often needed to validate a user control in aspx page but document.getElementById('controlname') does not get us that usercontrol.
 
Suppose we create a user control that has only asp:text box named 'txt', and we have to validate it in our page.
 
<myText:Textbox ID="txt" runat="server" Visible="true"  />
    <asp:Button ID="btnSumbit" runat="server" Text="Validate user control" OnClientClick="javascritp:return IsFilled()" />
 
You can use the following JavaScript to get that control.
 
var a=document.getElementById('form1').elements("txt$txt");
    if(a.value=='')
    {
        alert("please enter value");
        return false;
    }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bajrang Singh
Software Developer (Senior) Siemens IT Solutions and Services Pvt. Ltd.
India India
I am a .NET Developer.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140814.1 | Last Updated 13 Jun 2011
Article Copyright 2011 by Bajrang Singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid