Firstly, “Modifying” may be the wrong term, I see a few people have posted online just asking whether they can actually modify an embedded resource. What I am wanting to to, is use a resource in my assembly as a kind of template which I would do a find and replace on before registering it on the page – is this possible?
For example; say I have a few lines of jQuery as an embedded resource in my assembly and in this script I am referencing a CSS class name that can be set by the front-end programmer. Since I do not know what the CSS class will be until implementation, is there a way of going through the embedded resource and replacing, say, $myclass$ with ThisClassName.
Any help would be appreciated, if it’s not possible then at least tell me so I can stop chasing my tail.
I have solved my little issue by creating an HTTP Handler. In this instance it’s called DynamicClientScript.axd.
I have taken a few cuts from my code to give you an idea. The code below gets the standard embedded resource URL and takes the query string from it to add to the path to my handler.
The handler then takes its query string to build the URL to the standard resource. Reads the resource and replaces each key with it’s value within the dictionary collection (DynamicClientScriptParameters).
The paramGuid is an identifier used to get the correct script parameter collection.
What the handler does…
Then in my code where I want to reference my resource I use the following.
Then say my script resource contains:
It will output as if it was:
My code also does some caching (using the DynamicScriptSessionManager) but you get the idea…
Cheers