模式弹出里面没有工作的UpdatePanel [英] Modal Popup not working inside UpdatePanel

查看:129
本文介绍了模式弹出里面没有工作的UpdatePanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我里面的UpdatePanel一个gridview。在一个GridView中列的是点击链接应显示模式时(我使用zurb该模式 HTTP ://www.zurb.com/playground/reveal-modal-plugin )。问题是模态只得到只显示一次链接被点击的时候,当链接被点击它在下一次只刷新页面。点击gridview的内部链接时的情态应显示每次。

模态脚本:

 函数popupModal()
{
    $(a.link)。点击(函数(五){
        亦即preventDefault();
        $('#myModal #modalContents')负载($(本).attr('HREF'));
        $('#myModal)显示()。
    });
}

GridView的:

 < ASP:的ScriptManager ID =smgr=服务器的EnablePartialRendering =真/>
< ASP:的UpdatePanel ID =upnlSearchResults=服务器RenderMode =内联>
    <&的ContentTemplate GT;
        < ASP:GridView控件ID =gvResult=服务器的AutoGenerateColumns =false的>
            <柱体和GT;
                < ASP:BoundField的数据字段=雇员的HeaderText =雇员ID/>
                < ASP:的TemplateField的HeaderText =>
                    <&ItemTemplate中GT;
                        < / TD>< / TR>
                        &所述; TR>
                            &所述; TD列跨度=10>
                                < A HREF =Department.aspx级=链接>详细信息< / A>
                            < / TD>
                        < / TR>
                    < / ItemTemplate中>
                < / ASP:的TemplateField>
            < /专栏>
        < / ASP:GridView的>
    < /&的ContentTemplate GT;
    <&触发器GT;
        < ASP:AsyncPostBackTrigger控件ID =btnSearch/>
    < /触发器>
< / ASP:的UpdatePanel>    < D​​IV ID =myModal级=透露峰>
         < D​​IV ID =modalContents>< / DIV>
         &所述;类别=近距离揭示峰>&放大器;#215;&下; / A>
    < / DIV>

code要绑定GridView和注册模式弹出

 保护无效btnSearch_Click(对象发件人,ImageClickEventArgs E)
{
    VAR的结果= _ presenter.GetEmployers();
    gvResult.DataSource =结果;
    gvResult.DataBind();    ScriptManager.RegisterStartupScript(this.Page,this.Page.GetType(),弹出,popupModal();,真正的);}


  

编辑:我试着调试JavaScript和code链断裂线的地方
  揭示了弹出

 函数popupModal()
    {
        $(a.link)。点击(函数(五){
            亦即preventDefault();
            $('#myModal #modalContents')负载($(本).attr('HREF'));
            $('#myModal)显示()。 - > [在此行中抛出错误。]
        });
    }


  
  

由于我使用zurb模式,它由jquery.reveal.js文件
  它由显示功能。该功能popupModal是我
  单独的js文件employee.js。由于该错误消息是什么
  像这样的对象不支持属性或方法透露在IE中,我
  一旦弹出模态获取显示首次我假设,它
  找不到从jquery.reveal.js文件显示功能。


谁能帮我解决这个问题?

Sanjeev


解决方案

OK终于找到了解决办法。不知道,但你不能在项目中引用的jquery.js文件两次。我曾在师父的文件引用我的jquery.js文件,我在我的Department.aspx文件相同的参考。摆脱重复的jQuery的参考,它只是正常工作。

I have a gridview inside UpdatePanel. One of the column in gridview is link which when clicked should display modal (i am using zurb modal http://www.zurb.com/playground/reveal-modal-plugin). The problem is the modal only gets displayed only once when the link is clicked, the next time when the link is clicked it just refreshes the page. The modal should be displayed everytime when the link inside the gridview is clicked.

Modal Script:

function popupModal()
{
    $("a.link").click(function (e) {
        e.preventDefault();
        $('#myModal #modalContents').load($(this).attr('href'));
        $('#myModal').reveal();
    });
}

GridView:

<asp:ScriptManager ID="smgr" runat="server" EnablePartialRendering="true" />
<asp:UpdatePanel ID="upnlSearchResults" runat="server" RenderMode="Inline">
    <ContentTemplate>       
        <asp:GridView ID="gvResult" runat="server" AutoGenerateColumns="false">                   
            <Columns>
                <asp:BoundField DataField="EmployeeID" HeaderText="Employee ID"  />
                <asp:TemplateField HeaderText="">
                    <ItemTemplate>
                        </td></tr>
                        <tr>
                            <td colspan="10">
                                <a href="Department.aspx" class="link">Detail Information</a>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSearch" />
    </Triggers>
</asp:UpdatePanel>

    <div id="myModal" class="reveal-modal">
         <div id="modalContents"></div>
         <a class="close-reveal-modal">&#215;</a>            
    </div>

Code To Bind GridView and Register Modal PopUp

protected void btnSearch_Click(object sender, ImageClickEventArgs e)
{
    var results = _presenter.GetEmployers();
    gvResult.DataSource = results;
    gvResult.DataBind();

    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "popUp", "popupModal();", true);

}

Edit: I tried to debug javascript and the code breaks in line where it reveals the popup

   function popupModal()
    {
        $("a.link").click(function (e) {
            e.preventDefault();
            $('#myModal #modalContents').load($(this).attr('href'));
            $('#myModal').reveal(); -> [throws error in this line.]
        });
    }

Since i am using zurb modal, it consists of jquery.reveal.js file which consists of reveal function. The function popupModal is in my separate js file employee.js. Since the error message is something like this 'Object doesn't support property or method 'reveal' in IE, i am assuming once the popup modal gets displayed for the first time, it can't find the reveal function from the jquery.reveal.js file.

Can anyone help me fix this issue?

Sanjeev

解决方案

ok finally found the solution. didn't know but you couldn't reference jquery.js file twice in the project. I had reference to my jquery.js file in Master file and i had same reference in my Department.aspx file. Got rid of duplicate jquery reference and it just worked fine.

这篇关于模式弹出里面没有工作的UpdatePanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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