使用QueryString [英] Using QueryString

查看:84
本文介绍了使用QueryString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


非常感谢您的即时回复.我将更清楚,更详细地说明我的问题

这是我在第一页中的代码.

Hi,
Thanks a lot for your immediate response. I will explain my problem clearly and in more detail

this is my code in first page.

protected void btnLogin_Click(object sender, EventArgs e)
    {
        string pusername = NameTextBox.Text;
        Response.Redirect("~/OrderForm.aspx?username=" + pusername);
    }



这是我在第二页中的代码



this is my code in second page

protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          string username = Request.QueryString["pusername"];
          lblWelcome.Text += "Welcome," + username ;
      }
  }



当我尝试在第二页中获取此变量pusername时,我没有得到它.你能告诉我可能是什么错误吗?如果我尝试使用其在查询字符串中的位置来检索此值,则它将起作用.
请像我提到的那样告诉我如何使用变量.



when I try to get this variable pusername in the second page, I am not getting it. Can you please tell what could be the error. If i try it retrieve this values using their position in the querystring then it works.
Please tell me how to do with variables as I mentioned.

推荐答案

而不是这样:
Instead of this:
string username = Request.QueryString["pusername"];



为此:



do this:

string username = Request.QueryString["username"];


您的querystring变量是''用户名''& "pusername"是用于在上一页中分配值的变量.


Your querystring variable is ''username'' & ''pusername'' is a variable used to assign value in previous page.


这篇关于使用QueryString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆