Reputation: 15571
I have a solution with a couple of projects. Both use inline expression syntax, such as:
<p><a runat="server" href="<%=MyProject.Global.PathSite %>">My Link</a></p>
Assuming that MyProject.Global.PathSite equates to
public const String Whatever = @"http://www.myurl.com/";
At both design time and at runtime project A, the first project that I created in the solution, evaluates the expression correctly, while project B, the second project that I created a couple of months later, evaluates the expression as
%3c%25=MyProject.Global.PathSite%20%25%3e
Basically, ASP.Net treads <% %> as HTML text rather than a tag that it should process, while the second one does not.
Any thoughts?
UPDATE: I reworked the wording of the question to better make sense.
Upvotes: 0
Views: 138
Reputation: 15571
After suffering with this issue for a couple of weeks, I finally figured out the problem.
The problem is that you cannot use <% %> in any tag, where the runat attribute is server. You can use <% %> on client side tags only.
For tags that are runat server, then simply go to the Page_Load event and enter the property through the code behind.
Upvotes: 1
Reputation: 1355
Try putting <%=MyProjectName.ClassName.PublicProperty %> in a literal with runar=server, you could do that with both in fact.
Upvotes: 0