ASP.net实现页面跳转的方法
主要是使用response的属性,代码如下:
protected void linkbutton1_click(object sender, eventargs e)
{
string url = "infoshow.aspx";
response.redirect(url);
}
protected void linkbutton1_click(object sender, eventargs e)
{
string url = "infoshow.aspx";
response.redirect(url);
}//当然我们可以在页面跳转的时候进行参数传递,代码如下:
protected void menu1_menuitemclick(object sender, menueventargs e)
{
string url, s;
s = e.item.value.tostring();
url = "inforelease.aspx?username=" + s.trim();
response.redirect(url);
}
protected void menu1_menuitemclick(object sender, menueventargs e)
{
string url, s;
s = e.item.value.tostring();
url = "inforelease.aspx?username=" + s.trim();
response.redirect(url);
}
上面是我的一个项目中的代码所以有item,大家可以根据自己的情况进行设定。
那么既然传递了参数,在跳转的页面怎样获取呢???
代码如下:
protected void page_load(object sender, eventargs e)
{
if (request["username"] != null)
{
string s = request["username"].tostring();
// form1.visible = true;
txtinfoclass.text = s;
}
}
protected void page_load(object sender, eventargs e)
{
if (request["username"] != null)
{
string s = request["username"].tostring();
// form1.visible = true;
txtinfoclass.text = s;
}
}
protected void page_load(object sender, eventargs e)
{
txtalert.text = "";
if (request["username"] != null)
{
string s = request["username"].tostring();
// form1.visible = true;
txtinfoclass.text = s;
}
}
protected void page_load(object sender, eventargs e)
{
txtalert.text = "";
if (request["username"] != null)
{
string s = request["username"].tostring();
// form1.visible = true;
txtinfoclass.text = s;
}
}