1

I've got the following ASP.NET 4 MVC 3 code in a view:

@Html.TextBoxFor(model => model.StateName, 
  new { data_provider = "typehead", data_items = "5", data_source = 
   "['Alabama','Alaska','Arizona','Arkansas','California']" })

The above is rendered on the page as:

<input data-items="5" data-provider="typehead" 
  data-source="[&#39;Alabama&#39;,&#39;Alaska&#39;,&#39;Arizona&#39;,&#39;Arkansas&#39;,&#39;California&#39;]" 
  id="StateName" name="StateName" type="text" value="" />

How do you display the data_source value unencoded? I'ved tried the @Html.Raw(content) as well as @MvcHtmlString.Create(content) with no luck.

2
  • Did my answer get you want you wanted? :) Commented Mar 30, 2012 at 21:26
  • Not quite, though I appreciate your help. We wrote a script block and created this var names = @Html.Raw(['Alabama','Alaska', 'Arizona', 'Arkansas', 'California']") $('.typeahead-StateName').typeahead( {source:names} ); Commented Apr 1, 2012 at 8:27

1 Answer 1

1

If you use JQuery with the following line:

$("#PersonName").data("source")

This returns:

['Alabama','Alaska','Arizona','Arkansas','California']

Is this what you want?

JSFiddle: http://jsfiddle.net/jEWF3/1/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.