asp.net mvc - Razor encodes quoted html attributes -


i'd conditionally render appropriate html client using construct:

<input type="button" value="foo" @(string.isnullorempty(model.identifier) ? string.format("title={0} disabled=disabled", "lorem ipsum") : "onclick=window.open('http://www.google.com'); return false;") /> 

this output get:

<input type="button" value="foo" title=&quot;lorem ipsum&quot; disabled=disabled /> 

i've tried numerous html.raw() constructs, nothing seems of help. how output correctly unencoded html quotes instead of html entities?

try this. tried , worked me. difference singular quotations marks , html.raw around whole thing

<input type="button" value="foo" @html.raw(string.isnullorempty(model.identifier) ? string.format("title='{0}' disabled='disabled'", "lorem ipsum") : "onclick='window.open(\"http://www.google.com\"); return false;'") /> 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -