Reputation: 10564
String.Format("args.{0} = '{1}'", dynaform.RequiredModelName, dynaform.RequiredModel)
Expected result:
args.myVariable = 'someOtherStuff'
Actual result:
args.myVariable = 'someOtherStuff'
Second attempt:
Html.Raw(String.Format("args.{0} = '{1}'", dynaform.RequiredModelName, dynaform.RequiredModel))
Result:
Object reference not set to an instance of an object.
How can I tell String.Format
to output '
as '
and not as '
?
This is really frustrating and, since now, I had to avoid String.Format when dealing with '
or "
Upvotes: 0
Views: 2264
Reputation: 111
From the specs: Creates an HTML-encoded string using the specified text value.
In the posted code:
MvcHtmlString.Create(String.Format("args.{0} = '{1}'", dynaform.RequiredModelName, dynaform.RequiredModel))
Upvotes: 5