zoukankan      html  css  js  c++  java
  • ASP.Net中传递参数的常见方法

    ASP.Net中传递参数的常见方法

    标签:

    参数传递

    第一种ASP.Net参数传递方法:
    通过URL链接地址传递
    send.aspx:
    protected void Button1_Click(object sender, EventArgs e)
    {
            Request.Redirect("Default2.aspx?username=honge");
    }
    receive.aspx:
    string username = Request.QueryString["username"];这样可以得到参数值。
    第二种ASP.Net参数传递方法:
    send.aspx
    <form id="form1" runat="server" action="receive.aspx" method=post>
        <div>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    <asp:TextBox ID="username" runat="server"></asp:TextBox>
    </div>
        </form>
    receive.aspx
    string username = Ruquest.Form["receive"];
    第三种ASP.Net参数传递方法:

    send.aspx:
    protected void Button1_Click(object sender, EventArgs e)
        {
            Session["username"] = "honge";

            Request.Redirect("Default2.aspx");
        }
    receive.aspx:

    string username = Session["username"];这样可以得到参数值。

    第四种ASP.Net参数传递方法:
    send.aspx:
    protected void Button1_Click(object sender, EventArgs e)
        {
            Application["username"] = "honge";
            Request.Redirect("Default2.aspx");
        }
    receive.aspx:
    string username = Application["username"];这样可以得到参数值。

    第五种ASP.Net参数传递方法:
    send.aspx:

    public string Name
        {
            get {
                return "honge";
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Server.Transfer("Default2.aspx");
        }
    receive.aspx:
       send d = Context.Handler as send ;
            if (d != null)
            {
                Response.Write(d.Name);这样可以得到参数值。
            }

    原文地址:http://blog.sina.com.cn/s/blog_6158b3f90100r2a7.html

  • 相关阅读:
    PHP trim() 函数
    php 计算2个日期的相差天数
    php date('Y-n-j')的和date('Y-m-d')的区别
    转移服务器
    Invalid argument supplied for foreach()解决办法
    wordpress 后台忘记密码怎么办
    qrcode js插件生成微信二维码
    thinkphp5 注释
    tp5 新增完数据,获取id
    resstFul服务文件上传下载
  • 原文地址:https://www.cnblogs.com/wancy86/p/2208768.html
Copyright © 2011-2022 走看看