2010-08-13 5 views
2
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> 

<!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></title> 
</head> 
<body> 
    <form id="form1" runat="server" method="post"> 
    <div> 

    </div> 
    </form> 
</body> 
</html> 



namespace WebApplication1 
{ 
    public partial class _Default : System.Web.UI.Page 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 
      Response.Redirect("/WebForm1.aspx?ID=100"); 
     } 
    } 
} 

Deuxième pagevaleur querystring en utilisant la méthode post asp.net

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %> 

<!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></title> 
</head> 
<body> 
    <form id="form1" runat="server" method="post"> 
    <div> 

    </div> 
    </form> 
</body> 
</html> 

    protected void Page_Load(object sender, EventArgs e) 
      { 
       string ID = Request.QueryString["ID"].ToString(); 
      } 

Je suis en train d'obtenir la valeur querystring en utilisant la méthode post, mais la valeur n'est pas récupéré. S'il vous plaît Aide

+0

Quelle erreur avez-vous obtenu? Peut-être un null lorsque id n'existe pas? – Aristos

+0

Ce n'est pas une question de test. Parfois, la valeur n'est pas transmise et parfois la chaîne de requête est ajoutée à l'URL. –

+0

La valeur querystring est toujours visible dans l'URL. –

Répondre

1

Ou essayez

string ID = Request.Params.Get("ID"); 
Questions connexes