Buttons inside facebox popup don't postback (fix)

I was developing an asp.net page that has popups in facebox,

one of these popups had a button with a postback behavior and code behind to execute,

unfortunately the postback behavior didn't run properly,

when i clicked that button it looked like a client side button with no postback behavior,

after googling this problem with no results, i had to edit facebox.js file myself to get around this problem,

here's the solution and explanation

Solution:

1. in facebox.js go to this line: $('body').append($.facebox.settings.faceboxHtml)

2. replace it with $('#aspnetForm').append($.facebox.settings.faceboxHtml)

that would fix the problem,

Explanation:

if you look into facebox.js file, facebox appends the div that pops up inside the body of the page not inside the form,so clearly you should place that div inside the asp.net form to enable button's postback,

 

Have fun...

10 Comments

  • hi,
    i have a aspx page which i am loading using facebox. In the form i have a button which submits the form.on clicking the button the facebox closes and its opening the page which is loading in the facebox in other page.
    can we make the facebox remain like that and make the form in the loading page work?

    thanks in advance

  • Hey venkat,
    can you please explain your problem in more details,
    also tell me the scenario of the case you are solving in details,

    one more thing is that you can use updatepanel inside the page to make it don't post back

  • Hi,

    I am using a web user control which has a panel that contains labels, drop down list, textbox and a button control.

    And this control is implemented using Jquery facebox in a web form. I am not able to click the button for post back
    even after modifying the .js file.

    Is it because I am using a user control.

    Please guide me asap
    Thanks.

  • hi, i have question, how can i execute facebox() from code behind (c#). for example i have login form and on button event i have try {} catch { load the popup}.

  • this sulution is not working in IE

  • Hi, I'm having the same issue as venkat above. I have a pop up with facebox that gives the user the ability to pick an item from a listbox and then click a submit button (asp:button)... on click of the button the form opens in a full size browser screen (like a redirect). I want the facebox to post the aspx form back and then close itself. -

  • Hi, I have followed your example and my problem is as follows. If I leave the 'body' in the js file go I can get the facebox div to show and then onclick the asp:button makes the facebox disappear however it does not fire the button click event.
    If I change the js file to the above "#aspnetForm" it does not show the facebox at all on the click of the link. Any help would be appreciated

  • 73GY2k I think this is a real great article post.Really looking forward to read more. Awesome.

  • YD2HLl Hey, thanks for the blog article.Really thank you! Really Great.

  • Rxwd0U Very good blog article.Really looking forward to read more. Will read on...

Comments have been disabled for this content.