Click here to Skip to main content
12,765,176 members (38,737 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 12 Jun 2011

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");
        alert("please enter value");
        return false;


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


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


Comments and Discussions

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