Mega Code Archive

 
Categories / ASP.Net / Asp Control
 

Link Javascript function to OnClientClick event

<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>Popup Date Selector</title>     <script language="javascript" type="text/javascript">     function PickDate(controlName)     {         var wnd = null;         var settings = 'width=300,height=200,location=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=yes';         var url = 'Popup.aspx?control=' + controlName;         wnd = window.open(url,'DatePopup',settings);         if (wnd.focus){ wnd.focus(); }     }     </script> </head> <body>     <form id="form1" runat="server">     <div>     Start Date:     <asp:TextBox ID="txtDateStart" runat="server" Columns="10"></asp:TextBox>     <asp:ImageButton ID="btnDateStart" runat="server"         ImageUrl="~/images/cal_allday.gif"         OnClientClick="PickDate('txtDateStart')" />     <br />     End Date:     <asp:TextBox ID="txtDateEnd" runat="server" Columns="10"></asp:TextBox>     <asp:ImageButton ID="btnDateEnd" runat="server"         ImageUrl="~/images/cal_allday.gif"         OnClientClick="PickDate('txtDateEnd')" />     </div>     Press enter key to continue.     </form> </body> </html>