Click here to Skip to main content
15,891,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using session method to retrieve a string value at another page in my asp.net application. But i want to retrieve that value at multiple pages. I mean there will be one source (from where i am passing a string) and multiple destinations (where i will retrieve my string value). How i can do that? Please help me.

What I have tried:

//at source page
Session["Name"] = TextBox1.Text;
Response.Redirect("4page1_index.aspx");

//at destination page

if (Session["Name"] != null)
{
s = Session["Name"].ToString();
Response.Write(s);
}

//but in that case there is just one destination, while i want to show that string(from text1.text in that case) to multiple pages.
Posted
Updated 21-Mar-17 6:48am
v2
Comments
Karthik_Mahalingam 21-Mar-17 13:28pm    
same as your code, what is the issue you are facing
Hassaan_Malik 21-Mar-17 13:36pm    
But in my code , the destination is just one page. But i want to to retrieve that value(from textbox) to multiple pages. Mean i have multiple destinations. But in my above mentioned code there is just one destination.
Karthik_Mahalingam 21-Mar-17 23:26pm    
Always use  Reply  button, to post Comments/query to the user, so that the user gets notified and responds to your text.
Karthik_Mahalingam 21-Mar-17 23:27pm    
yes it will work. show the code for "multiple destinations"

Simply copy and paste that code where it needs to go, or you could make it into a user control and simply place the user control on pages where you want the output.

If you're asking how you can add this to other pages without amending those pages then that would be more bother than it's worth really, you'd need to implement a custom response filter, but if you want to do that because you can't be bothered updating the pages you need this on that is the wrong solution.
 
Share this answer
 
Comments
Hassaan_Malik 21-Mar-17 12:56pm    
can you suggest me any useful web link from where i could get idea/help about implementation,cos i am new asp.net?
The value which stores in session and can be retrieved through out the application.

If in first page you store a value in session.
Ex: Session["KeyName"]="AnyValue";

That session can be retrieved in every page in the application.

In 2nd page:

String s="";
if (Session["KeyName"] != null)
{
s = Session["KeyName"].ToString();
Response.Write(s);
}


In 3rd page:

String s="";
if (Session["KeyName"] != null)
{
s = Session["KeyName"].ToString();
Response.Write(s);
}

Same as Session value can be retrieved.
 
Share this answer
 
Comments
Hassaan_Malik 21-Mar-17 13:08pm    
I tried it. Its not working. I created a session at one page in my application. Then at another page i retrieved that value. But its not retrieving.
Ramesh Kumar Barik 21-Mar-17 13:18pm    
Refer this link it may help you

http://www.c-sharpcorner.com/UploadFile/225740/introduction-of-session-in-Asp-Net/
Hassaan_Malik 21-Mar-17 13:41pm    
I have seen that link. In that link, just one destination page is used. (Same as my code which i have posted above). But i want to display that string value to multiple pages.. . . .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900