There are several ways to pass values between pages in ASP.NET without using Session. Here are some examples:
Query string: You can pass values between pages using query string parameters. For example, to pass a value called "id" with a value of 123 to another page, you can use a URL like this:
http://example.com/otherpage.aspx?id=123
In the receiving page, you can retrieve the value of the "id" parameter using the Request.QueryString property:
string id = Request.QueryString["id"];
Cookies: You can also pass values between pages using cookies. For example, to set a cookie with a value of "123" that can be accessed on another page:
HttpCookie cookie = new HttpCookie("myCookie"); cookie.Value = "123"; Response.Cookies.Add(cookie); In the receiving page, you can retrieve the value of the cookie using the Request.Cookies property:
HttpCookie cookie = Request.Cookies["myCookie"]; if (cookie != null) { string value = cookie.Value; } Cross-page posting: If you have a form that submits to another page, you can pass values between the pages using the PostBackUrl property of the form. For example, to pass a value called "id" with a value of 123 to another page when a button is clicked:
<form id="myForm" runat="server" method="post" action="otherpage.aspx" PostBackUrl="otherpage.aspx?id=123"> <asp:Button ID="myButton" runat="server" Text="Submit" /> </form>
In the receiving page, you can retrieve the value of the "id" parameter using the PreviousPage property:
if (PreviousPage != null) { string id = PreviousPage.Request.QueryString["id"]; } These are just a few examples of ways to pass values between pages without using Session. The best approach depends on your specific needs and the type of data you need to pass.
"ASP.NET pass values between pages without Session"
// C# code using QueryString Response.Redirect("YourPage.aspx?parameterName=value"); "ASP.NET cross-page postback without Session"
<!-- ASP.NET markup for source page --> <form id="form1" runat="server" PostBackUrl="TargetPage.aspx"> <!-- Your form controls --> </form>
// C# code in TargetPage.aspx.cs string parameterValue = Request.Form["parameterName"];
"ASP.NET pass values using Server.Transfer without Session"
// C# code in SourcePage.aspx.cs Context.Items["parameterName"] = parameterValue; Server.Transfer("TargetPage.aspx", true); // C# code in TargetPage.aspx.cs string parameterValue = Context.Items["parameterName"].ToString();
"ASP.NET pass values using cookies without Session"
// C# code in SourcePage.aspx.cs HttpCookie cookie = new HttpCookie("parameterName", parameterValue); Response.Cookies.Add(cookie); Response.Redirect("TargetPage.aspx"); // C# code in TargetPage.aspx.cs string parameterValue = Request.Cookies["parameterName"].Value;
"ASP.NET pass values using ViewState without Session"
// C# code in SourcePage.aspx.cs ViewState["parameterName"] = parameterValue; Server.Transfer("TargetPage.aspx", true); // C# code in TargetPage.aspx.cs string parameterValue = ViewState["parameterName"].ToString();
"ASP.NET pass values using URL parameters without Session"
// C# code using Response.Redirect Response.Redirect("TargetPage.aspx?parameterName=" + parameterValue); // C# code using Server.Transfer Context.Items["parameterName"] = parameterValue; Server.Transfer("TargetPage.aspx", true); // C# code in TargetPage.aspx.cs string parameterValue = Request.QueryString["parameterName"];
"ASP.NET pass values using TempData without Session"
// C# code in SourcePage.aspx.cs TempData["parameterName"] = parameterValue; Response.Redirect("TargetPage.aspx"); // C# code in TargetPage.aspx.cs string parameterValue = TempData["parameterName"].ToString();
"ASP.NET pass values using Cross-Page PostBack without Session"
<!-- ASP.NET markup for source page --> <asp:TextBox ID="txtParameter" runat="server"></asp:TextBox> <asp:Button ID="btnSubmit" runat="server" PostBackUrl="TargetPage.aspx" Text="Submit" />
// C# code in TargetPage.aspx.cs string parameterValue = ((TextBox)PreviousPage.FindControl("txtParameter")).Text; "ASP.NET pass values using Application state without Session"
// C# code in SourcePage.aspx.cs Application["parameterName"] = parameterValue; Server.Transfer("TargetPage.aspx", true); // C# code in TargetPage.aspx.cs string parameterValue = Application["parameterName"].ToString();
"ASP.NET pass values using Cross-Page PostBack with PreviousPage without Session"
<!-- ASP.NET markup for source page --> <asp:TextBox ID="txtParameter" runat="server"></asp:TextBox> <asp:Button ID="btnSubmit" runat="server" PostBackUrl="TargetPage.aspx" Text="Submit" />
// C# code in TargetPage.aspx.cs string parameterValue = ((TextBox)PreviousPage.FindControl("txtParameter")).Text; single-page-application ionicons vba bulk-load iot screen-scraping set-returning-functions managed-bean mjpeg c#-6.0