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="lorem ipsum" 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
Post a Comment