Click here to Skip to main content
12,627,681 members (29,884 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

9.4K views
1 bookmarked
Posted

How to validate a user control in ASPX page

, 13 Jun 2011 CPOL
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.

You may also be interested in...

Pro
Pro

Comments and Discussions

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