Thursday 8 November 2012

How to call Javascript Function




Calling Javascript  in Codes



There are two ways to call javascript function in asp.net:

Consider this Javascript Function: 
<script type="text/javascript">
    function ClosePopup() {
        window.close;
        return false;
    }
</script>

Method 1:

<asp:Button ID="btnCancel" runat="server" OnClientClick="javascript:ClosePopup()" Text="Cancel"
            Height="23px" Font-Bold="True" ForeColor="White"  
            BackColor="#990000" Width="175px"/>


Method 2:

And By calling the javascript in codes:

 protected void btnCancel_Click(object sender, EventArgs e)
 {
    btnCancel.Attributes.Add("OnClick", "ClosePopup()");
 }






No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top