Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass parameters to the page if I use Server.Execute method

Status
Not open for further replies.

Plato2

Programmer
Dec 6, 2002
192
US
I want to use Server.Execute method and I need to pass parameters to that page how can I do that?

Thanks in advance
 
The easiest way is using QueryString
Code:
Server.Execute("mypage.aspx?id=1");
In mypage.aspx Page_Load
Code:
string id = Request.QueryString["id"];

You can get output back from the executed page using a StringWriter. Here's ht eframework documentation for this


I'm not sure but with Server.Transfer the Form collection of the calling page is available within the page you transfer to using Request.Form. I would imagine this is the same for Server.Execute.

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Is there is any other way to pass parameters? For server.execute

Thanks
 
Whats wrong with the querystring? Do you want to pass an object to the page rather than a value?

You could store them in the Session or the Cache and pull them back in the executed page I guess.

AFAIK there is no Server.Execute specific mechanism for passing parameters. Just the same as are available to the page if called directly by the browser ie. Request.QueryString and Request.Form.

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Yeah you could put them in the context collection too.

What are you using the executed page for? If you don't mind me asking?

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
I'm trying to execute a page and then convert that page to StringWriter and email it....

Alex
 
Ok - that is probably one of the few valid uses of Server.Execute. I have seen people use it to encapsulate functionality (as we did in classic ASP) before which is kind of missing the point a bit I feel. As you don't need the parameters after the email has been sent the Context collection seems a good place to put them.

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top