Click here to Skip to main content
15,920,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have one dropdown list and two textboxes on usercontrol page and I want to validate that dropdown and textboxes from aspx page using Javascript. Here is the code for the usercontrol:
XML
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Search.ascx.cs" Inherits="Search" %>
<table bgcolor="#A1B0B3" width="100px">
 <tr>
  <td>
   <asp:Label ID="Status" runat ="server" Text ="Status" Width ="90px">
  </td>
 <td>
  <asp:DropDownList ID="ddlstatus" runat ="server" Width ="90px"> <%-- <asp:DropDownList ID="ddlSt" runat ="server">--%>
 </td>
<td>
 <asp:Label ID="lblSdate" runat ="server" Text ="ShippingDate" Width ="90px"> 
</td>
<td>
 <asp:TextBox ID="txtSdate" runat ="server" Width ="90px">
   
   DD/MM/YYYY
</td>
<td>
   <asp:Label ID="lblDdate" runat ="server" Text ="Delivery Date" Width ="90px">
</td>
<td>
<asp:TextBox ID="txtDdate" runat ="server" Width ="90px" >
   DD/MM/YYYY
</td>
<%--<td>
   <asp:Button ID="btnsearch" runat ="server" Text ="Search" />
</td>--%>

</tr> 
</table>
Posted
Updated 15-Dec-10 21:53pm
v4
Comments
Dalek Dave 16-Dec-10 3:53am    
Edited to show full code.

Hi malisager ,

To validate a control inside a user control you have to access control by client id.

You can refer this link.


[^]
 
Share this answer
 
hi,
just write the function for validatin the control in javascript..
if u r using clas in java script write the code like this
functionName: function()
{
$get(clientID+txtSdate).value=""
.
.
} 

you can check the value by using a if condition.
u can replace $get by document.getElementById()..and you shud write the client Id +control id for finding the control..you can also get the dropdown value by coding like this..
 
Share this answer
 
Check below link


How javascript validate of User control using asp.net

Vote up if the answer is suitable :)
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900