A.aspx page
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" codefile= "A.aspx.cs" inherits= "Ordermanage_a"%>
<%@ Register src= ". /usercontrol/ctrlcalendar.ascx "Tagname=" Ctrlcalendar "tagprefix=" uc1 "%>"
<title></title>
<script language= "javascript" type= "Text/javascript" >
function GetValue ()
{
var Txpro=document.getelementbyid (' <%=txtprovider_rename. ClientID%> ');
When you get the value of a server control with JS, you first get the ClientID of the server control
var Txdat=document.getelementbyid (' <%=txtcheckin.clientid%> ' + "_txtdateval");
Using JS to get the server control values in the. ascx control, first get the server control's ClientID plus the server space ID inside the. ascx page and connect with "_"
Txpro.value=txdat.value;
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<div>
<tr>
<TD align= "Right" bgcolor= "#dee5fa" > Check-in dates </td>
<TD align= "left" bgcolor= "#dee5fa" ><uc1:ctrlcalendar id= "Txtcheckin" runat= "Server"/></td>
</tr>
<tr>
<TD align= "Right" bgcolor= "#dee5fa" onclick= "GetValue ()" ><asp:textbox id= "Txtprovider_rename" runat= " Server "Width=" 312px ></asp:TextBox></td>
</tr>
</div>
</form>
</body>
Ctrlcalendar.ascx
Copy Code code as follows:
<%@ control language= "C #" autoeventwireup= "true" codefile= " CtrlCalendar.ascx.cs "inherits=" Ctrlcalendar%>
<table id= "Table1" style= "height:24px" cellspacing= "0" cellpadding= "0" width= "border=" 0 ">
<tr>
<td style=" width:81px "><font face=" Arial "> Br><asp:textbox id= "Txtdateval" width= "84px" runat= "Server" borderstyle= "Groove" ></asp:textbox></ font></td>
<td><div id= "Div_imgcanlendar" ><font face= "song Body" ></font></div></td>
</tr>
</table> br>