jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用JQuery Mobile Dialog的ASP.NET Gridview大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在努力尝试将ASP.NET Gridview链接JQuery Mobile对话框,该对话框将用于编辑Gridview中的数据.

我的目标是使用GridView显示数据.用户将单击一行,对话框将打开一个带有FormView的对话框,用户可以编辑所选行的数据.我使用JQuery UI对话框可以正常工作,但是当我切换到Jquery Mobile时,事情就崩溃了.

现在,如果我在iOS设备或BlackBerry上运行它,对话框会在屏幕上闪烁一秒钟.如果我在Windows中运行它可以正常工作.我不确定我做错了什么.

这是我的aspx页面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="myTest.aspx.cs"    Inherits="MySite.myTest" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test</title>
    <style type="text/css">
        .hover
        {
            BACkground-color: Gray;
        }
    </style>
    <script type="text/javascript">
    function clickRow() {
        //Had to put in $(document).ready or I got PostBACk errors.
            $(document).ready(function () {
                $.mobile.changePage("#dialogPage",'pop',true,truE);
            });
        }
    </script>
</head>
<body>
     <form id="form1" runat="server">
       <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div data-role="page" id="mainpage">
        <div data-role="content">
        ...GridView goes here...
        <a href="#dialogPage" id="lnkDialog" data-rel="dialog">Click Me</a>
    </div>
    </div>        
   <div data-role="dialog" id="dialogPage">
    <div data-role="content">
        ... FormView goes here....         
    </div>

    </form>

</body>
</html>

这里有一些代码背后:

protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs E)
    {
        if (e.Row.RowType == DataControlRowType.Da@R_269_2301@w)
        {
            //Allows user to click/tap anywhere on gridview row to trigger SELEcTindexChange
            e.Row.Attributes["onmouSEOver"] = "this.oldClass = this.className;this.className='hover';";
            e.Row.Attributes["onmouSEOut"] = "this.className=this.oldClass;";
            e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBACkClientHyperlink(GridView1,"SELEct$" + e.Row.RowIndex.ToString());
        }
    }

    protected void GridView1_SELEctedIndexChanged(object sender,EventArgs E)
    {
        //This should open dialog
        ClientScript.RegisterStartupScript(typeof(PagE),"test","clickRow()",truE);
    }

我认为问题在于我在$(document).ready()函数中包装$.mobile.changePage()函数的方式.如果我不这样做,我会收到回发错误.我不确定这样做的正确方法.

如果我尝试使用< a data-rel =“对话框”打开对话框>< / a>链接,它适用于所有设备.

谢谢你的建议.

解决方法

我记得遇到过类似的情况.要记住的是,在处理jQuery mobile时,位于头部内的脚本标签不会在后续页面上加载.尝试将脚本块移动到用作页面标记内.

大佬总结

以上是大佬教程为你收集整理的使用JQuery Mobile Dialog的ASP.NET Gridview全部内容,希望文章能够帮你解决使用JQuery Mobile Dialog的ASP.NET Gridview所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。