asp.net mvc - How do I add a css class to the TempData output? -


the tempdata output plain text , putting div around leave formatted empty div on screen if there no tempdata.

is there way apply class shows when tempdata item set?

other writing div code tempdata, seems horrible idea.

i write helper:

public static class htmlextensions {     public static string message(this htmlhelper htmlhelper, string key)     {         var message = htmlhelper.viewcontext.tempdata[key] string;         if (string.isnullorempty(message))         {             return string.empty;         }         var builder = new tagbuilder("div");         builder.setinnertext(message);         return builder.tostring();     } } 

which used so:

<%= html.message("somekeytolookintempdata") %> 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -