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.
Querystring. Source page - Response.Redirect("second.aspx?param=value");
Destination page - Request.QueryString["param"].
Session.Source page - Session["param"] = "value"; value is set here.
Destination page - Session["param"].ToString(). value is retrieved here.
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" %>.
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"].
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
Consider using session or query string.
Session could be used like
pass value
Session["value"]=someValue;
get value like
var value= Session["value"].toString();
You could pass values with the help of properties too
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With