2012-06-06 63 views
0

我有登錄的Default.aspx頁面。成功登錄後,它顯示ItemValuation.aspx頁面,但在地址欄中顯示的鏈接是Default.aspx。這個問題是在我的項目中給jquery加註後開始的。如果我刪除了jquery 引用和代碼,則顯示的鏈接在登錄後顯示無誤,即ItemValuation.aspx 任何人都可以告訴我如何解決這個問題?在Default.aspx上成功登錄後,地址欄中顯示的鏈接應該是ItemValuation.aspx爲了您的參考,我發佈了Default Page 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> 

//Default.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); 

      } 

     } 



} 

} 
+0

代碼在哪裏? –

+0

Ahh引用缺失(我的意思是你的代碼):) – V4Vendetta

+0

ohh對不起...這是代碼。 :) – Scorpian275

回答

2

jQuery Mobile的是,在做了一個。默認情況下,它會通過AJAX更改所有鏈接和表單提交。

要禁用此...趣味...功能,您需要向mobileinit事件添加處理程序,並將ajaxEnabled設置爲false

Docs here on how how do this:http://jquerymobile.com/demos/1.1.0/docs/api/globalconfig.html

+0

哇!這對於其他用戶只是在jquery.mobile中更改-1.1.0.js找到ajaxEnabled,它是ajaxEnabled:true,將其設置爲ajaxEnabled:false ...........完成... Thanx馬特。 – Scorpian275

+0

謝謝大家。 – Scorpian275