protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["userid"] != null)
{
userid = Request.QueryString["userid"].ToString();
}
else
{
userid = "";
}
if (userid == "")
{
if (hf1.Value == "no")
{
userid = "no";
}
else if (hf1.Value == "yes")
{
userid = "yes";
}
}
switch (userid)
{
case "no": cd = "userid is null"; hf1.Value = "no"; break;
case "yes": cd = "userid!=''"; hf1.Value = "yes"; break;
default: cd = "userid!=''"; break;
}}
====================
问题是:
当我首次点击一个链接如:
<a href="index.aspx?userid=no">大</a>
时得到hf1.Value值为no了.....
当我第二个点击本页面上一个链接如:
<a href="?type=oye">试试</a>时.这时的hf1.Value值为空了...发现没值了???
[hf1为HiddenField控件..]
{
if (Request.QueryString["userid"] != null)
{
userid = Request.QueryString["userid"].ToString();
}
else
{
userid = "";
}
if (userid == "")
{
if (hf1.Value == "no")
{
userid = "no";
}
else if (hf1.Value == "yes")
{
userid = "yes";
}
}
switch (userid)
{
case "no": cd = "userid is null"; hf1.Value = "no"; break;
case "yes": cd = "userid!=''"; hf1.Value = "yes"; break;
default: cd = "userid!=''"; break;
}}
====================
问题是:
当我首次点击一个链接如:
<a href="index.aspx?userid=no">大</a>
时得到hf1.Value值为no了.....
当我第二个点击本页面上一个链接如:
<a href="?type=oye">试试</a>时.这时的hf1.Value值为空了...发现没值了???
[hf1为HiddenField控件..]
<a href="index.aspx?userid=no">大 </a> if (Request.QueryString["userid"] != null)
为TRUE.
执行IF下面代码..
为HiddenField控件赋值.你点第二个页面上的链接.
<a href="?type=oye">试试 </a>
没有链接地址,只是刷新本页面.
一刷新,页面上所有控件都重新加载.
以前赋给HiddenField控件的值就没有了..
这是你也没有通过URL传值给第二个页面.
if (Request.QueryString["userid"] != null)
为FALSE.
不执行IF下面代码..
不为HiddenField控件赋值.