我在 .net 和 JQM 中使用母版页编写了两页。但是当我重定向到第二页时,JQM 滑动控件在没有刷新的情况下不起作用。此外,像简单的 alert() 这样的任何控件或功能都不起作用。我正在分享我的代码:
母版页:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="UserMaster.master.cs" Inherits="Password.Masters.UserMaster" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript">
$(document).on("pageinit", "#demo-page", function () {
$(document).on("swipeleft swiperight", "#demo-page", function (e) {
if ($.mobile.activePage.jqmData("panel") !== "open") {
if (e.type === "swiperight") {
$("#left-panel").panel("open");
}
}
});
});
</script>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<div data-role="page" id="demo-page" data-theme="d">
<div data-role="header" data-theme="b" class="ui-header ui-bar-b" role="banner">
<h1>Web Page</h1>
<a href="#left-panel" data-theme="d" data-icon="arrow-r" data-iconpos="notext" data-shadow="false" data-iconshadow="false" class="ui-icon-nodisc">Open left panel</a>
</div>
<div data-role="panel" id="left-panel" data-theme="b">
<!---->
<ul data-role="listview" data-theme="d">
<li data-icon="arrow-r" data-theme="b">Welcome
<asp:LoginName ID="LoginName1" runat="server" />
</li>
<li data-icon="home"><a href="../Pages/Home.aspx" data-rel="">Homepage</a></li>
</ul>
</div>
<div data-role="content">
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</div>
</div>
</body>
</html>
Slide.aspx(它是一个空页面):
<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/UserMaster.Master" AutoEventWireup="true" CodeBehind="Slide.aspx.cs" Inherits="Password.Pages.Slide" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
Home.aspx(这也是一个空页面):
<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/UserMaster.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="Password.Pages.Home" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
我想在使用母版页的每个页面中使用滑动控件,但是当我使用左侧滑动面板从 Slide.aspx 转到 Home.aspx 时,滑动控件不起作用。当我刷新页面时,它就可以工作了。按钮控件也是如此(例如)。我怎样才能让它工作?是关于“pageinit”的问题吗?那么 document.ready() 呢?我尝试了所有可能的解决方案,但都失败了。谢谢。