Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are many things You can do.</p> <pre><code>1.Cross Page Scripting </code></pre> <p>One of the problems faced by us in ASP.NET 1.x versions is the inability to transfer data between pages easily. Since ASP.NET 1.x pages postback to the same page by default, and you cannot do a post to another page (unless you remove the runat="server" and other messy things), accessing the controls in the previous page becomes very difficult unlike classic ASP where you have a action tag to specify the new page and you can use the Request.Form to access the previous page values.</p> <p>There is a more effective way of accessing the Controls in the previous page in ASP.NET 2.0. Its using the PreviousPage property of the Page.</p> <p>Say we have a page Default.aspx with a Textbox "Text1" and a Button "Button1".</p> <p>We can access the controls in Default.aspx from another page by the following steps:-</p> <p>A. Setting the PostBackUrl property of the Button to the New Page, as follows:-</p> <pre><code>&lt;asp:Button ID="button1" Runat=server Text="submit" PostBackUrl="~/NewPage.aspx" /&gt; </code></pre> <p>B. Then, in the NewPage.aspx.cs, you can access the TextBox control on Default.aspx as follows:-</p> <pre><code> public void page_load() { if(!IsPostBack) { TextBox tb = (TextBox)PreviousPage.FindControl("Text1"); Response.Write(tb.Text);} } </code></pre> <p>Note that a new TextBox tb is declared and typecasted using the PreviousPage and FindControl of the ID of the Control in the Previous Page. However, to retain the value across postbacks within the new page, its better to assign the text to a TextBox or Label in the NewPage.aspx such that its value is not lost across postbacks. The reason behind is that, the PreviousPage becomes invalid once you postback in the same page. </p> <pre><code>2.Sessions </code></pre> <p>You can refer the below link for help <a href="http://asp.net-tutorials.com/state/sessions/" rel="nofollow">http://asp.net-tutorials.com/state/sessions/</a> example Session["Value"]="Any Data"; You can access it in any page </p> <pre><code>3.Cookies </code></pre> <p>Creating a Cookie Object</p> <pre><code>HttpCookie _userInfoCookies = new HttpCookie("UserInfo"); </code></pre> <p>Setting values inside it</p> <pre><code>_userInfoCookies["UserName"] = "Abhijit"; _userInfoCookies["UserColor"] = "Red"; _userInfoCookies["Expire"] = "5 Days"; </code></pre> <p>//Adding cookies to current web response</p> <pre><code>Response.Cookies.Add(_userInfoCookies); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload