地址栏显示上一页的地址

本文关键字:地址 一页 显示 地址栏 | 更新日期: 2023-09-27 18:36:25

我有默认.aspx页面用于登录。成功登录后,它会显示项目评估.aspx页面,但在地址栏中显示的链接是默认.aspx。问题开始于我在项目中插入jquery之后。如果我删除 jquery引用和代码,然后登录后显示的链接是正确的,即项目评估.aspx谁能告诉我如何解决这个问题?成功登录默认后.aspx地址栏中显示的链接应为项目评估.aspx 供您参考,我正在发布默认页面aspx代码。提前谢谢。

   <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Item_Valuation.Default"  %>
<!DOCTYPE html  >
<html >
<head runat="server">
<link rel="shortcut icon" href="~/Images/ACME.ico">
    <title>Login</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0;"/> 
    <link href="css/jquery.mobile-1.1.0.min.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery-ui-1.8.18.custom_mini.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="js/jquery.mobile-1.1.0.min.js" type="text/javascript"></script>
</head>
<body >
 <div data-role="page" id ="loginpage" data-theme="c" >
    <form id="formLogin" runat="server" >
    <div id ="DivHeader" data-role="header"  data-position="fixed" data-theme="c"  >
   <div style="text-align:center;top:4px;">
        <asp:Image ID="Image1" runat="server" 
            ImageUrl="Images/ItmVlun.jpg"   />
   </div>
    </div>
    <div data-role="content" style=" margin-top: 2px;">
    <table style="text-align:right;width:100%">
    <tr>
    <td style="width:80%" >
    <table  style="border-color: #FFCC00;width:100%;left:5%; text-align:left;">
    <tr>
      <td style="width:50%;"><asp:Label ID="lblLogin" runat="server" Text="Login:" 
              Font-Bold="False" Font-Names="Copperplate Gothic Light" Font-Size="Large"></asp:Label>
         </td>
      <td style="width:50%;"><input id="txtUserName" type="text" runat="server" style="width:100%;font-size:large;"   /></td>
      <td><ASP:RequiredFieldValidator ControlToValidate="txtUserName"
           Display="Static" ErrorMessage="*" runat="server"  
           ID="vUserName" /></td>
      </tr>
   <tr>
      <td >
          <asp:Label ID="lblPassword" runat="server" Text="Password:" Font-Bold="False" 
              Font-Names="Copperplate Gothic Light" Font-Size="Large"></asp:Label>
       </td>
      <td  ><input id="txtUserPass" type="password" runat="server" style="width:100%;font-size:large;"   /></td>
         </tr>
   <tr>
      <td >
          <asp:Label ID="lblRememberMe" runat="server" Text="Remember Me:" 
              Visible="False" Font-Names="Copperplate Gothic Light"></asp:Label>
       </td>
      <td >
          <asp:CheckBox ID="chkPersistCookie" runat="server" autopostback="false" 
              Visible="False" />
       </td>
      <td ></td>
   </tr>
   </table>
   </td>
   <td style="width:20%;"> 
       <asp:Image ImageAlign=Right ID="Image2" runat="server" 
           ImageUrl="~/Images/LogInimg.jpg"  Width="100%" Height=60% />
   </td>
        </tr>
      </table>  
</div>
  <div  data-role="footer"  data-position="fixed" data-theme="c">
  <asp:Button ID="btnLogIn" runat="server" OnClick="LogMe_Click"
      Text="Log in" data-theme="a"  CausesValidation="False" data-role="button"  data-inline="true" style=" float : left;"  />
  <input type="button" ID="CloseButton"  value="Close" onclick ="window.close();" />
  <asp:Label ID="lblMsg" runat="server" ForeColor="#FF0066"  style=" float : Right;" ></asp:Label>
    </div>
    </form>
    </div>
</body>
</html>

默认.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; 
using System.Web.Security;
//using System.Web.UI.MobileControls;
using System.Runtime.InteropServices;

namespace Item_Valuation
{
    public partial class Default : System.Web.UI.Page
    {
       // internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);
        //public static string IMEI;
        Item_Valuation.User usr;
        public static string message="";
        public string AuthorisationMsg;
        protected void Page_Load(object sender, EventArgs e) 
        {
            try
            {
                if (!IsPostBack)
                {
                    if (Request.QueryString["TCPServer"] != null)
                    {
                        AuthorisationMsg = Request.QueryString["TCPServer"].ToString();
                        GlobalData.SetSettings();
                        lblMsg.Text = "Error: TCP Server IP " + GlobalData.TCPServer + " " + AuthorisationMsg;
                    }
                    else if (Request.QueryString["Message"] != null)
                    {
                        lblMsg.Text = Request.QueryString["Message"].ToString();
                    }

                }
                txtUserName.Focus();
            }
            catch (Exception ee)
            {
                lblMsg.Text = ee.Message;
            }
       }

        private bool ValidateUser(string userName, string passWord)
        {
            if ((null == userName) || (0 == userName.Length))
            {
                return false;
            }

            try
            {
                string msg = "";
                Item_Valuation.User Usr = Item_Valuation.User.CheckLogin(userName, passWord, ref msg);
                if (msg.Length > 0)
                {
                    lblMsg.Text = msg;
                    Response.Write("<script>'alert("+lblMsg.Text +"')</script>"); 
                    return false;
                }
                if (Usr != null)
                {
                }
                else
                {
                    lblMsg.Text = "Invalid Login id or Password";
                    Response.Write("<script>'alert(" + lblMsg.Text + "')</script>"); 
                    return false;
                }
            }
            catch (Exception ex)
            {
                // AcmePayRollBusiness.PayRollError.PostError(this.GetType(), ex, "Error while validating User");
                return false;
            }
            return true;
        }
        public void LogMe_Click(object sender, EventArgs e)
        {
            if (ValidateUser(txtUserName.Value, txtUserPass.Value))
            {
                FormsAuthenticationTicket tkt;
                string cookiestr;
                HttpCookie ck;
                tkt = new FormsAuthenticationTicket(1, txtUserName.Value, DateTime.Now,
                  DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data");
                cookiestr = FormsAuthentication.Encrypt(tkt);
                ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
                if (chkPersistCookie.Checked)
                    ck.Expires = tkt.Expiration;
                ck.Path = FormsAuthentication.FormsCookiePath;
                Response.Cookies.Add(ck);
                string strRedirect=null;
                //strRedirect = Request["ReturnUrl"];
                usr = (Item_Valuation.User)HttpContext.Current.Session["User"];
                int roleLevel = usr.RoleLevel;
                if (roleLevel != 1)
                {
                    if (strRedirect == null)
                        strRedirect = "ItemValuation.aspx";
                }
                else
                {
                    if (strRedirect == null)
                        strRedirect ="PrinterAssignment.aspx";
                }
                Response.Redirect(strRedirect);
                //Server.Transfer(strRedirect);
            }
        }

}
}

地址栏显示上一页的地址

jQuery Mobile就是这样做的。默认情况下,它会更改通过 AJAX 提交的所有链接和表单。

要禁用此功能...有趣。。。功能,您需要向 mobileinit 事件添加处理程序,并将ajaxEnabled设置为 false

有关如何执行此操作的文档:http://jquerymobile.com/demos/1.1.0/docs/api/globalconfig.html