tags:

views:

17

answers:

2

I am utilizing controls in my asp.net application. I have a register tag the source of which needs to be dynamic. I am using the line below which functions correctly when the full path is specified but when I change it to the variable I get a parser error. Any idea how I can go about doing this?

Thanks

<%@ Register TagPrefix="leftNav" TagName="sectionLeftNav" Src="/inc/testLeftNav-" & myVar & ".ascx" %>

+1  A: 

If I'm understanding you correctly — you can't use a variable in those directives (Page, Register, etc). They have to be constant expressions.

However, it is possible to dynamically load ASCX controls. You would have to do this in code, though, and it would not involve the Register tag.

harpo
+2  A: 

It might be better to use Load Control from the code behind of the aspx page.

Simon Hazelton
+1 for the right solution!!
rockinthesixstring