Handling a mix of server side code and html in a resource file?

Posted by Brandon on Stack Overflow See other posts from Stack Overflow or by Brandon
Published on 2010-03-30T18:57:51Z Indexed on 2010/03/30 19:23 UTC
Read the original article Hit count: 162

Filed under:
|
|

I'm trying to convert an ASP.NET web application to use resource files. I haven't used resource files before, so I'm just toying around with them and was wondering if this is possible.

I have a message that returns from a search when no results are found, that prompts the user to return to the home page. A lot of these pages have methods to determine what is the proper page to send the user to, so there are many sections with markup similar to this:

Sorry, but we could not find an item matching your search criteria.

Please adjust your search criteria or <a href="<%= SomeMethodToDetermineUri() %>">return to (SomePage)</a>.

So basically, some type of message, followed by a link or a list of links. Getting the message part works fine, it's the server side code to generate links thats the problem.

What is the best way to put that into a resource file? It is able to recognize the html link part just fine, but the server side code gets inserted as plain text.

Is the only way to break it into 2 resources? (Which seems messy)

<%= Resources.Master.NoSearchResultsFound %>
<a href="<%= SomeMethodToDetermineUri() %>"> 
   <%= Resources.Master.NoSearchResultsFoundReturnLinkText %>
</a>.

Or is there a way to get the page to evaluate the server code?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET