Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to pass the query string to a page generated at runtime this code is in web service please help.

code:
C#
Page nk = new Page();
     UserControl ct1 = (UserControl)nk.LoadControl("~/testusercontrol.ascx");
     nk.Controls.Add(ct1);
     StringWriter wrs = new StringWriter();

     HttpContext.Current.Server.Execute(nk, wrs, false);
     return wrs.ToString();
Posted
Updated 5-Jan-12 22:42pm
v2
Comments
anushripatil 6-Jan-12 6:43am    
if in the page where you are writing this code, you are getting the querystring, then you add a hidden field to your page and You can pass the querystring to a hiddenfield .

I assume this generated code sits in some sort of handler or page.
If its a handler the handler object would have the ability to get the querystring request object.

Then before creating the page object "nk" you could assign the query string there and add directly to your code
eg.

var qstringvariable = request.querystrin....
Page nk = new Page();
UserControl ct1 = (UserControl)nk.LoadControl("~/testusercontrol.ascx");
ct1.<property needing="" querystring=""> = qstringvariable
nk.Controls.Add(ct1);
 
Share this answer
 

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