欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【2个页面间不通过Session与url的传值方式】,下面是详细的分享!
2个页面间不通过Session与url的传值方式
下面是全部代码,已经编译通过。
Chuandi(传递)是名字空间
WebForm1:
<%@Pagelanguage="c#"Codebehind="WebForm1.aspx.cs"Inherits="chuandi.WebForm1"%>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<body>
<formid="Form1"method="post"runat="server">
<asp:TextBoxid="TextBox1"runat="server"></asp:TextBox>
<asp:Buttonid="Button1"runat="server"Text="传"></asp:Button>
</form>
</body>
</HTML>
usingSystem;
namespacechuandi
{
publicclassWebForm1:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.TextBoxTextBox1;
protectedSystem.Web.UI.WebControls.ButtonButton1;
publicstringText1
{
get
{
returnthis.TextBox1.Text;
}
}
privatevoidPage_Load(objectsender,System.EventArgse)
{}
overrideprotectedvoidOnInit(EventArgse)
{
InitializeComponent();
base.OnInit(e);
}
privatevoidInitializeComponent()
{
this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);
this.Load+=newSystem.EventHandler(this.Page_Load);
}
privatevoidButton1_Click(objectsender,System.EventArgse)
{
Server.Transfer("WebForm2.aspx");
}
}
}
WebForm2:
<%@Pagelanguage="c#"Codebehind="WebForm2.aspx.cs"Inherits="chuandi.WebForm2"%>
<%@ReferencePage="WebForm1.aspx"%>
<HTML>
<HEAD>
<title>WebForm2</title>
</HEAD>
<body>
<formid="Form1"method="post"runat="server">
<asp:Labelid="Label1"runat="server">Label</asp:Label>
<asp:Buttonid="Button1"runat="server"Text="返回"></asp:Button>
</form>
</body>
</HTML>
usingSystem;
namespacechuandi
{
publicclassWebForm2:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.ButtonButton1;
protectedSystem.Web.UI.WebControls.LabelLabel1;
publicchuandi.WebForm1wf1;
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(!IsPostBack)
{
wf1=(chuandi.WebForm1)Context.Handler;
Label1.Text="上页传来的是:"+wf1.Text1;
}
}
overrideprotectedvoidOnInit(EventArgse)
{
InitializeComponent();
base.OnInit(e);
}
privatevoidInitializeComponent()
{
this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);
this.Load+=newSystem.EventHandler(this.Page_Load);
}
privatevoidButton1_Click(objectsender,System.EventArgse)
{
Server.Transfer("WebForm1.aspx");
}
}
以上所分享的是关于2个页面间不通过Session与url的传值方式,下面是编辑为你推荐的有价值的用户互动:
相关问题:html页面之间不通过URL,如何传值??
答:使用 cookies 当然, 也可以使用 b.html?args... 进行传值 举个例子: Name : Tel : Name : Tel : var url_vars = split_vars(); function split_vars() { var sch = location.search.substring(1); var vars = sch.split("&"); for(var i = 0; i ... >>详细
相关问题:html之间的传值问题,用什么方法好?
答: //a.php 回 我想把从数据库里提取的值,譬如帖子编号rs['id'],用post的方法传到别的文件、 ////// 为了实现这样的效果,你可以先在a.php页面把那个值下放到html中 比如。 当前访问的页面时a.php >>详细
相关问题:ASP.NET页面之间传递值的几种方式
答:URL、Session、Cookies、Server.Transfer、Application和跨页面传送。 【分析】 本题考查面试者对ASP.NET中多页面传值的理解是否全面。因为ASP.NET的页面表单提交到自身,完成回传的功能,所以默认情况下不能使用POST方式进行多页面传值。关于这... >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
