Link Javascript function to OnClientClick event : Image Button « Asp Control « ASP.Net






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>

 








Related examples in the same category

1.Determining the Coordinates Clicked on the Image of an ImageButton Control (VB.net)
2.Simple ImageButton control (VB.net)
3.asp:ImageButton AlternateText (VB.net)
4.For loop inside asp:ImageButton Click event (VB.net)
5.Set ImageUrl for asp:Image (VB.net)
6.Use Image Button event (VB.net)
7.Deal with button action event arguments: x, y coordinates (C#)
8.Get Image Button mouse cursor coordinates (C#)
9.Get position from ImageClickEventArgs