?
Solved

set variable in Page_Load and then get the value in another sub

Posted on 2006-07-24
3
Medium Priority
?
273 Views
Last Modified: 2008-03-17
Hi,

I do this to set a variable:
private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here
                   string strVar =Request.ServerVariables["HTTP_REFERER"];
                  
            }
How do I retrieve this variable in ibtnSubmit_Click?

0
Comment
Question by:FullWilliams
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Expert Comment

by:proten
ID: 17168274
Define the variable before the page_load sub, you now can access it in all subs:

string strVar

private void Page_Load(object sender, System.EventArgs e)
          {
               // Put user code to initialize the page here
                string strVar =Request.ServerVariables["HTTP_REFERER"];
               
          }
0
 
LVL 33

Accepted Solution

by:
raterus earned 1000 total points
ID: 17169096
I'm assuming these are not the same request, or else you could just pull from Request.ServerVariables in btnSubmit.

I'd add the property to viewstate (works just like the session, only it's page based), if you are accessing this across requests, proten's solution will not work.

0
 

Author Comment

by:FullWilliams
ID: 17175061
Thanks raterus.

viewstate and session both worked.  

Session["myvar"] = Request.ServerVariables["HTTP_REFERER"];
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question