[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 599
  • Last Modified:

call another page without showing in asp.net using C#.net

hello,

1st -- don't give me referrels website links send me the valid and working code.. and don't send the code of VB or other i want C#.net (only) and ASP.net

2nd -- my query is:

i have 2 pages; in my first page when i click button then server side code intiate and then i want to call the page2 without showing the page .. and process the data on page2 then i get the session and i want to use that session on first page ... so thats why i some that call page2 with showing and process my data on page2 page_load event .. and then i get the session which was created by page2 and show the data output on page1..

Thanks
0
AVARICESOFT
Asked:
AVARICESOFT
5 Solutions
 
Kusala WijayasenaSoftware EngineerCommented:
What do you mean by "get the session which was created by page2". What is the requirement of that ?

-Kusala
0
 
shrinivasmwCommented:
Do this....

Page1 code :

ButtonClick Event()
{
     Response.Redirect("Page2.aspx");
}

Page2 code

Page_Load()
{
     //Do Session related activity ;
     Session["newValue"] = value ;
     Response.Redirect("Page1.aspx");
}

Now you will be again in Page1 and you will get the session value : Session["newValue"]

--------------- 2nd approach
Derive your page1 from page2 and do whatever you want to do in Page2's page load event.

Let me know if this solves ur issue.
0
 
hehdaddyCommented:
You could always put the Page 2 processing in a class that you can call from Page 1. You can indeed access the Session data from the class using context. Then you never have to transfer away from Page 1.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
Gary DavisDir Internet SvcsCommented:
If you do not want to have the round trip(s) to the user's browser, use Server.Transfer() or Server.Execute().
Gary Davis
0
 
amar31282Commented:
Hmm well i don't know why u have this requirement but you can use this way also


In the page load of page2 use this

this.Visible = false;

and do what ever you want to do in this page save the values in session and then redirect this page to page1 and you can use the session there..

I hope this is what you want..

Cheers

Amarjit Singh
0
 
amar31282Commented:
strange acceptance...


0
 
shrinivasmwCommented:
Yes, I also agree.... THIS IS STRANGE ACCEPTANCE OF SOLUTION......
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now