0

我有一个登录页面,单击登录按钮时,它会重定向到另一个 .aspx 页面,但带有回发。我希望不会发生单击按钮回发的情况。我想使用json。但我不知道如何在我的页面中使用它以及如何调用它。请告诉我如何避免使用 json 回发。我想为移动设备构建一个应用程序并使用 jquery 移动设备。

My code is
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>
    </title>
    <link href="CSS/jquery.mobile-1.1.1.min.css" rel="stylesheet" type="text/css" />

    <link href="CSS/my.css" rel="stylesheet" type="text/css" />

    <script src="Js/jquery.min.js" type="text/javascript"></script>

    <script src="Js/jquery.mobile-1.1.1.min.js" type="text/javascript"></script>
     <script src="Js/my.js" type="text/javascript"></script>

</head>
<body>
<form id="form1" runat="server">
<%-- <asp:ScriptManager ID="scriptmngr" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="upnlData" runat="server" UpdateMode="Conditional">
<ContentTemplate>--%>
<div data-role="page" data-theme="d" id="page1">
        <div data-theme="b" data-role="header"> 
            <h3>
            </h3>
            <div style="">
                <img style="width: 100px" src="Images/QuickMove.png" />
            </div>
        </div>
        <div data-role="content" style="padding: 15px">

      <div>
                <p>
                    <b>
                        <span style="background-color: rgb(255, 255, 0);" data-mce-
style="background-color: #ffff00;">
                        </span>
                        <span style="background-color: rgb(255, 255, 255); color:   
rgb(255, 102, 0);">
                            ​Survey Login
                        </span>
                    </b>

                </p>
            </div>
            <div data-role="fieldcontain" style="width:100%">
            <label  ID="lblLoginMsg" SkinID="snkError" runat="server" 
ForeColor="Maroon" Font-Bold="True"
                    Font-Size="Small"></label>
                <fieldset data-role="controlgroup">
                    <label for="textinput2"><span style="font-family: times new 
roman,times; font-size: medium;">
                        <strong>
                            Username
                        </strong>
                    </span>
                    </label>
                    <input name="" id="txtUserName" placeholder="" value="" type="text" 
runat="server"/>
                </fieldset>
            </div>

            <div data-role="fieldcontain" style="width:100%" >
                <fieldset data-role="controlgroup">
                    <label for="txtPassword"> <span style="font-family: times new 
roman,times; font-size: medium;">
                        <strong>
                            Password
                        </strong>
                    </span>
                    </label>
                    <input name="" id="txtPassword" placeholder="" value=""   
type="password" runat="server"/>
                </fieldset>
            </div>
             <div data-role="fieldcontain" style="width:100%" >
       <%--   <button type="button"   data-transition="fade" data-theme="b" 
            data-icon="check" data-iconpos="right" id="btnSignIn" value="Sign In"     
runat="server"   onclick="btnSignIn_Click" />--%>
         <button id="btnSignIn" type="button" runat="server"   
onserverclick="btnclick">Sign In</button>
  </div>
<div data-theme="b" data-role="footer" data-position="fixed" >
<h4 style="font-size: 10px">

     &copy;QuickMove
</h4>
</div>        
</div>
</div>

</form>
</body>
4

2 回答 2

0

JSON是用于交换数据的数据表示,不用于通信,您需要 ajax 来验证用户,您可以使用jQuery Ajax。这是一篇很好的文章,开始使用jquery ajax 和 asp.net web 方法

于 2012-11-23T11:57:36.327 回答
0

您需要以一种或另一种方式发布,因为由于各种原因(包括安全性和 Web 标准),在 GET 中发送登录凭据根本没有完成,而且您也不能完全在客户端完成,因为那时客户端代码(根据定义被污染)将负责做出登录决定。

所以你确实需要一个 POST,但你可以避免<form>使用 AJAX 重新加载页面(这基本上意味着当用户提交 a 时,你不会告诉 Web 浏览器发出 POST 请求,而是从 javascript 发出请求并在回调中处理结果不离开页面)。jQuery 带有完整的 AJAX API,因此您无需深入了解 XmlHttpRequest 对象的细节及其在不同浏览器上的实现。

就 JSON 而言:JSON 是一种通用数据格式,也是 JavaScript 本身的子集。它是 AJAX 请求的标准格式,主要是因为它是轻量级的,内置于​​大多数当前的 JavaScript 实现中(并且相当快的实现可用于在需要时可以透明地接管的旧实现),并且易于生成和解析。

于 2012-11-23T12:04:21.447 回答