内部基础ASP按钮事件模态不触发 [英] asp button event inside foundation modal not firing

查看:91
本文介绍了内部基础ASP按钮事件模态不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图寻找一个解决方案,但似乎没有为我工作。我的问题是pretty直截了当虽然(所以,我认为)。

I have tried searching for a solution for this, but nothing seems to be working for me. My problem is pretty straightforward though (so, I think).

我使用与ASP的WebForms基础,有一个显示网页时加载的火灾模态窗口。

I am using foundation with asp webforms and have a reveal modal window that fires when the page is loaded.

code:

$(document).ready(function () { $('#myModal').foundation('reveal', 'open') });

以上工作正常,但是,任何时候我把一个ASP按钮模式内(一个我使用,btnReset,重定向到新的页面),点击它不会触发它相连的事件。

The above works fine, however, any time I put an ASP button inside the modal (the one I am using, btnReset, redirects to a new page), clicking on it will not fire the event attached to it.

code:

<div id="reset">
    <div class="large-2 columns">
        <asp:Button ID="btnReset" runat="server" Text="Reset" 
                    OnClick="btnReset_Click" OnClientClick="btnReset_Click"   
                    CssClass="button small radius alert" />
    </div>
</div>

code为btnReset:

Code for btnReset:

protected void btnReset_Click(object sender, EventArgs e)
{
     HttpCookie cookie = Request.Cookies["userInfo"];
     cookie.Expires = DateTime.Now.AddDays(-1);
     Response.Cookies.Add(cookie);
     Response.Redirect("LogIn.aspx");
     //Server.Transfer("LogIn.aspx");
}

我敢肯定,我错过了一些在这里,但我只是难倒我在做什么错。我怎样才能得到一个ASP按钮,并把它激发它的事件,当它是一个模式里?

I'm sure I am missing some here, but I'm just stumped on what I am doing wrong. How can I get an ASP button and have it fire it's event when it is inside a modal?

推荐答案

我知道这是问一个月前,但我遇到了同样的问题,发现没有解决这个问题。我发现在基金会论坛上解决了,我想我会在这里回答以供将来参考。

I know this was asked a month ago, but I ran into the same problem and found this question with no solution. I have found the solution over at the Foundation forums and thought I would answer it here for future reference.

这问题是如何粉底的补充模式。当您在开发工具看,你会看到,莫代尔,调用时,为之外制作无法访问背后的code中的ASP按钮的形式。

This issue is with how foundation adds your modal. When you look in your dev tools you will see that the modal, when called, is outside the form making the asp buttons unable to access the code behind.

这意味着我们需要的模态追加到表单,以便将按钮后面访问code。

This means we need to append the the modal to the form so that the buttons will access the code behind.

我尝试几种不同的方式使用appendTo的JavaScript来实现这一点,但发现最简单的方法就是化妆粉底使用的根元素形式。

I tried several different ways to achieve this in the javascript using appendTo, but found the easiest method was the make foundation use the root element form.

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

我发现在这里:埃琳娜Zhdanova解决方案

这篇关于内部基础ASP按钮事件模态不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆