c#中,方法的参数传递有几种?懂的简单说一下吧
通过URL链接地址传递 Request.Redirect("Default2.aspx?username=honge");
通过post方式:
<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"];通过session
send.aspx:
protected void Button1_Click(object sender, EventArgs e)
{
Session["username"] = "honge";
Request.Redirect("Default2.aspx");
}
receive.aspx:
string username = Session["username"];这样可以得到参数值常用的就是这种