简体   繁体   中英

Why my Asp button doesn't works even i added Onclick Event inside modal popup?

I have used ASP Button and added OnClick event in it, but while clicking the button it doesn't works. Kindly help me out to sort out this!

HTML:

 <asp:Button ID="Create_project" runat="server" Text="Create Project" OnClick="Create_project_Click"/>

Code Behind:

protected void Create_project_Click(object sender, EventArgs e)
    {
       Response.Write("Sucessfull");
    }

even i couldn't insert the values to database!

"Note: I am using this button(Create_project) inside the Ajax:modalpopupextender"

You need to post the markup of the button or control that pops this dialog.

Using the ajax dialog? then say we drop two buttons on the form. The first button click will display the dialog pop, and the 2nd one has our button.

So, say like this:

        <asp:Button ID="Button1" runat="server" Text="Button" Width="102px" />
        <ajaxToolkit:ModalPopupExtender ID="Button1_ModalPopupExtender" runat="server"
            BehaviorID="Button1_ModalPopupExtender"  TargetControlID="Button1"
            PopupControlID="mycoolpop" 
            >
        </ajaxToolkit:ModalPopupExtender>

        <div id="mycoolpop" 
            style="border:solid;border-width:2px;width:25%;box-shadow: 10px 5px 5px grey;padding:9px;">
            <h2>Cool pop dialog</h2>
            <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
        </div>

And we get this:

在此处输入图像描述

Now I in design mode double clicked on button2, and have this code:

   protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Write("The dialog button click");

    }

If I click on button2 (inside the dialog/modal), then a post-back will occur, and of course that will collopase the dialog (all post-backs do).

So, the we see this:

在此处输入图像描述

So, we need to see your markup, and what you doing and how you popping that dialog. Without you sharing that information, we can only take wild wild guesses as to what you actually doing here, and even worse guess as to what your problem is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM