Pass querystring to user control?

STEVESKI07

Member
Joined
Sep 12, 2007
Messages
17
Programming Experience
1-3
I'm trying to pass a querystring to a dynamically loaded user control and I'm getting an error saying that it is not a valid virtual path when I put on the querystring parameters. If I take out the querystring parameters it is working fine. Does anybody know of any way to do this?

Here is my code:
VB.NET:
Dim graphControl As Control
graphControl = LoadControl("~/User_Controls/BarGraph.ascx?id=CategoryCount")
plcGraph.Controls.Add(graphControl)

I know I could just use session variables if this is not possible, but is there any better way of doing this?
 
You don't pass the querystring to the usercontrol, instead when the user control loads the querystring is available to it through Request.QueryString. In other words, in the PageLoad event of the user control you can access the QueryString.
 
I'm trying to pass a value from the parent page to the user control. It isn't a querystring value in the parent page, so I will not be able to access it that way. I can just use the FindControl method to retrieve the value from the parent page, but the controls may be named differently on different pages so I'd rather not go that route.
 
a session variable sounds like the best option -- you could try a public property on the user control although i haven't much experience with those.
 
Back
Top