欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ASP.net实现页面跳转的方法

程序员文章站 2024-03-31 16:13:40
主要是使用response的属性,代码如下:复制代码 代码如下:protected void linkbutton1_click(object sender, eventa...

主要是使用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;
            }
        }