Click here to Skip to main content
15,911,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here the OK Button is not firing how can i call this button click event?

What I have tried:

JavaScript
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" MasterPageFile="~/AdminPanel/Admin.Master" Inherits="SSTeleCallerApp.WebForm2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        $(function () {
            $("[id*=Button2]").live("click", function () {
                $("#dialog").dialog({                                      
                    modal:true,
                    buttons: {
                        Ok: function () {
                             $("#<%=Button3.ClientID %>").click();
                            
                        },
                        Close: function () {
                            $(this).dialog('close');
                        }
                    }
                });
            });
        });
 </script>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
    
    <input type="button" id="Button2" value="click here" name="Button2" />

   
    <asp:Button ID="Button3" runat="server" Text="Button" style="display:none;" OnClick = "Button_Click"/>
    <div id="dialog">
        <asp:Label ID="Label1" runat="server" Text="Enter ur name">
        <asp:TextBox ID="TextBox1" runat="server" Text="karur">
    
    </div>



C#
<pre lang="c#">
protected void Button_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(Page.GetType(), "key", "alert('Button Clicked')", true);

}
Posted
Comments
Karthik_Mahalingam 20-Oct-16 12:17pm    
write alert() inside the ok function and check whether it alerts ?
Aashish68 21-Oct-16 0:43am    
yes alert works fine.But the Button_click event is not working.
Karthik_Mahalingam 21-Oct-16 2:59am    
try running this code in console window
find the element id by viewing the source in browser
$("#Button3ID").click();
Aashish68 21-Oct-16 3:11am    
sorry i can't understand.
Aashish68 21-Oct-16 9:11am    
is there any other solutions for button firing?

1 solution

Try this, its working for me
ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="WebApplication1.WebForm5" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
    <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/start/jquery-ui.css"
        rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $("[id*=Button2]").live("click", function () {
            $("#dialog").dialog({
                title: "jQuery Dialog Popup",
                buttons: {
                    Ok: function () {
                        $("[id*=Button3]").click();

                    },
                    Close: function () {
                        $(this).dialog('close');
                    }
                }
            });
            return false;
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button_Click" />
        <asp:Button ID="Button3" runat="server" Text="Button" Style="display: none" OnClick="Button3_Click" />
        <div id="dialog" style="display: none;">
            <asp:Label ID="Label1" runat="server" Text="Enter ur name"></asp:Label>
            <asp:TextBox ID="TextBox1" runat="server" Text="karur"></asp:TextBox>
        </div>
    </form>
</body>
</html>
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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