c# - How do I bring a string from one aspx.cs page to another? -


I want to use a string that I am using in an aspx.cs file from one to another. I know it's easy, but how do I do it?

You can do it in a query string. On your first page:

  Response Redirect ("second .aspx? Book = codecomplete");  

and on the second page

  string book = request ["book"];  

This method will allow your users to see what you are going to on the second page. Alternatively, you can put it in session object. To use it:

  session ["book"] = "codecopple";  

and to use it again:

  string book = session ["book"] in the form of a string;  

As a third option, you can use the server. If you want to go to the second page on the server side, then use this method but note that your user address The first page URL will continue on the bar.

on page 1:

  this.SomeProperty = "codecomplete"; Server.Transfer ("SecondPage.aspx");  

on page 2:

  string book = (previous page as page 1). Some properties;  

Comments