How to call jQuery UI Dialog with ASP NET button postback

0 votes

I have a jQuery UI Dialog working great on my ASP.NET page:

jQuery(function() {
    jQuery("#dialog").dialog({
        draggable: true,
        resizable: true,
        show: 'Transfer',
        hide: 'Transfer',
        width: 320,
        autoOpen: false,
        minHeight: 10,
        minwidth: 10
    });
});

jQuery(document).ready(function() {
    jQuery("#button_id").click(function(e) {
        jQuery('#dialog').dialog('option', 'position', [e.pageX + 10, e.pageY + 10]);
        jQuery('#dialog').dialog('open');
    });
});

My div:

<div id="dialog" style="text-align: left;display: none;">
    <asp:Button ID="btnButton" runat="server" Text="Button" onclick="btnButton_Click" />
</div>

But the btnButton_Click is never called... How can I solve that?

Apr 28, 2020 in Java-Script by kartik
• 37,510 points
3,071 views

1 answer to this question.

0 votes

Hello @kartik,

To solve the problem with ASP:Button event not firing inside jQuery modal. Please note, using the jQuery UI modal with the following allows the button event to fire:

// Dialog Link
$('#dialog_link').click(function () {
    $('#dialog').dialog('open');
    $('#dialog').parent().appendTo($("form:first"))
    return false;
});

The following line is the key to get this working!

$('#dialog').parent().appendTo($("form:first"))

Thank You!!

answered Apr 28, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to disable asp.net button after click to prevent double clicking?

Hello @kartik, On the front end, add these ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
7,628 views
0 votes
1 answer

How to manage a redirect request after a jQuery Ajax call?

Hii kartik, You can resolved this issue like ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
28,091 views
0 votes
1 answer

How to set outerHTML with jQuery?

hello @kartik, This is innterHTML because it's inside ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
1,810 views
0 votes
1 answer

How to manage a redirect request after a jQuery Ajax call?

Hii, You can solved this issue by: Adding a ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
3,177 views
0 votes
1 answer

Why it is necessary to refresh CSRF token per form request?

Hello, Generating a new CSRF token for each ...READ MORE

answered Mar 19, 2020 in Laravel by Niroj
• 82,880 points
4,088 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
2,901 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
949 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
2,962 views
0 votes
1 answer

How to disable postback on an asp Button in System.Web.UI.WebControls.Button?

Hello @kartik, Use this: <asp:button runat="server".... OnClientClick="myfunction(); return false;" ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
1,754 views
0 votes
1 answer

How to return JSON with ASP.NET & jQuery?

Hello @kartik, You need to do something like ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
2,062 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP