views:

144

answers:

1

I imagine this would be simple, but I can’t find an answer.

We set the theme of a page based on a query string parameter (like ‘?theme=theme1’ etc). I just want to know if there is an easy way to tell the theme name is valid, before setting it, or catching and handling the error if it is invalid.

The error I get if the theme does not exists is:

“Theme ‘theme1’ cannot be found in the application or global theme directories.”

I am not sure when the exception is thrown. All I can think of is searching the folder, but I would think there would be a simpler way.

Thanks

+1  A: 

Hey,

Check the theme against the list of theme folders; themes simply uses the folders of the name, so use Directory.Exists within System.IO.

Brian
Thanks for your answer.
zod