如何通过在asp.net web表单之间的信息 [英] How to pass information between web forms in asp.net

查看:123
本文介绍了如何通过在asp.net web表单之间的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从一个Web表单发送一些信息,在asp.net中另一个Web表单
第一个Web的形式为 HumanList.aspx 显示在 GridView控件部分人的名单。
当用户点击编辑链接,我想从 HumanList.aspx 通过humanID(人记录的ID值)到另一个名为Web表单 HumanEdit.aspx
在humanEdit.aspx,我想要加载,人类(使用 humanID ),并填写人信息转化为文本框。


解决方案

有很多方法可以通过PARAMS页之间。


  1. 使用查询字符串

Source页 - 的Response.Redirect(second.aspx参数=值?);

目标页 - 的Request.QueryString [参数]

<醇开始=2>
  • 使用会话

  • Source页 - 会话[参数] =值; 值在此处设置

    目标页 - 会话[参数]的ToString()。价值在这里检索。

    <醇开始=3>
  • 使用 previousPage 属性。注意:如果您从 first.aspx (这里只是举个例子)重定向这适用于 second.aspx ,然后您可以使用 previousPage&LT; PROPNAME&gt;在 second.aspx 在设定值 first.aspx

  • second.aspx 你需要添加指令,这样&LT;%@ previousPageType VirtualPath =〜/ first.aspx %方式&gt;

    <醇开始=4>
  • 使用的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.

    1. Use Querystring.

    Source page - Response.Redirect("second.aspx?param=value");

    Destination page - Request.QueryString["param"].

    1. Use Session.

    Source page - Session["param"] = "value"; value is set here.

    Destination page - Session["param"].ToString(). value is retrieved here.

    1. Use PreviousPage property. Note: This applies if you redirect from first.aspx ( just an example here), to second.aspx , then you can use PreviousPage.<propname> in second.aspx to values set in first.aspx.

    In second.aspx you need to add directive like this <%@ PreviousPageType VirtualPath="~/first.aspx" %>.

    1. 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"].

    1. Use cookies to transfer values. First save some value to cookie from first.aspx and read that value from second.aspx.

    Refer to MSDN for more info - MSDN link

    这篇关于如何通过在asp.net web表单之间的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆