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

Time:12-07

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"/>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

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"

CodePudding user response:

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:

enter image description here

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:

enter image description here

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.

  • Related