Menu icon Foundation
Asp.net/Foundation Reveal Modal

Simple question... with a .net button inside of a reveal modal, is it not possible to have the server side button control to a postback to the server? Inserting a breakpoint on the onclick event and it is not firing my code behind event.

.netbutton

Simple question... with a .net button inside of a reveal modal, is it not possible to have the server side button control to a postback to the server? Inserting a breakpoint on the onclick event and it is not firing my code behind event.

smta almost 6 years ago

me too have a same problem .. please if you have solution for this problem tel me
[email protected]

escher123 over 5 years ago

It actually does work, depending on how you are setup. Are you using WebForms?

Nadine Saadi over 5 years ago

Did this ever get solved? I'd like to know the answer.

Thanks

Elena Zhdanova over 5 years ago

Hi!

Revealed window is attached to body by default. in Asp.Net you need to have button inside "Form" tag, otherwise it won't send postback.
So, you need to configure reveal to attach to element inside "Form" tag, or simply use "Form" tag.
You can do it like this:

 <script>
    $(document).foundation();
    $(document).foundation('reveal', { rootElement: '#Form' });
</script>  

Reference - https://github.com/zurb/foundation/pull/3881

Tim Faase almost 5 years ago

The setting variable name has changed:

    $(document).foundation('reveal', { root_element: 'form' });

Chad Nelson about 4 years ago

To integrate this with an asp:Login Here is what worked for me:

    $(document).on('opened', '[data-reveal]', function () {
        $(this).appendTo($("form"));
    });

I also found this helpful: http://foundation.zurb.com/forum/posts/971-aspnet--reveal-no-value-in-controls-on-postback

Ross Berenson over 3 years ago

It seems like Foundation 6 Reveal no longer as the root_element option. That worked in the past for me quite well. Sadly the trick above doesn't seem to be working for me. Any other suggestions?

$(document).on('open.zf.reveal', '[data-reveal]', function () {
   $(this).appendTo($("form"));
});


When I attempted this trick. It "works" but the modal ends up not being in view. I also notice that there's a class added to the <body>. Seems like a lot has changes between F5 and F6 Reveal and I rather not have to edit the js. Thanks for any help in advance!

The Amigo about 3 years ago

Anyone found solution on how to do this in  Foundation 6?

Dustin Schneider about 3 years ago

 I'm also very interested in a fix for this in Foundation 6 - anybody have any ideas?

Lars Jensen almost 3 years ago

This is still a hack, but Ross' code above seems to work if you grab the parent element too:

        $(document).on('open.zf.reveal', '[data-reveal]', function () {
            $(this).parent().appendTo($("form"));
        });

Lars Jensen almost 3 years ago

FYI, this has been fixed in the Github repository (an appendTo setting was added so that reveals can be appended within the form as ASP.Net requires):

https://github.com/zurb/foundation-sites/blob/develop/js/foundation.reveal.js