如何通过在asp.net web表单之间的信息 [英] How to pass information between web forms in asp.net
问题描述
如何从一个Web表单发送一些信息,在asp.net中另一个Web表单
第一个Web的形式为 HumanList.aspx
显示在 GridView控件
部分人的名单。
当用户点击编辑链接,我想从 HumanList.aspx
通过humanID(人记录的ID值)到另一个名为Web表单 HumanEdit.aspx
。
在humanEdit.aspx,我想要加载,人类(使用 humanID
),并填写人信息转化为文本框。
有很多方法可以通过PARAMS页之间。
- 使用
查询字符串
。
Source页 - 的Response.Redirect(second.aspx参数=值?);
目标页 - 的Request.QueryString [参数]
会话
。 Source页 - 会话[参数] =值;
值在此处设置
目标页 - 会话[参数]的ToString()
。价值在这里检索。
previousPage
属性。注意:如果您从 first.aspx
(这里只是举个例子)重定向这适用于 second.aspx
,然后您可以使用 previousPage< PROPNAME>在 second.aspx
在设定值 first.aspx
。在 second.aspx
你需要添加指令,这样<%@ previousPageType VirtualPath =〜/ first.aspx %方式>
的Request.Form
阅读张贴的值。如果有输入
,的DropDownList
现有的源页面,你要留言值 second.aspx
,那么你可以使用读公布值的Request.Form [input_id]
。
- 使用
饼干
传递值。一是节省一些价值从first.aspx
来cookie并读取该值second.aspx
。
请参阅MSDN更多信息 - MSDN链接
how to send some information from one web form to another web form in asp.net
first web form is HumanList.aspx
that shows the list of humans in a GridView
component.
when user click edit link, i want to pass humanID (value of human record ID) from HumanList.aspx
to another web form named HumanEdit.aspx
.
In humanEdit.aspx, i want to load that human (With humanID
) and fill human information into text boxes.
There are many ways to pass params between pages.
- Use
Querystring
.
Source page - Response.Redirect("second.aspx?param=value");
Destination page - Request.QueryString["param"]
.
- Use
Session
.
Source page - Session["param"] = "value";
value is set here.
Destination page - Session["param"].ToString()
. value is retrieved here.
- Use
PreviousPage
property. Note: This applies if you redirect fromfirst.aspx
( just an example here), tosecond.aspx
, then you can usePreviousPage.<propname>
insecond.aspx
to values set infirst.aspx
.
In second.aspx
you need to add directive like this <%@ PreviousPageType VirtualPath="~/first.aspx" %>
.
- Use
Request.Form
to read posted values.
If there are input
, dropdownlist
existing in source page and you are posting value to second.aspx
, then you can read posted value using Request.Form["input_id"]
.
- Use
cookies
to transfer values. First save some value to cookie fromfirst.aspx
and read that value fromsecond.aspx
.
Refer to MSDN for more info - MSDN link
这篇关于如何通过在asp.net web表单之间的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!