As using ASP.NET MVC I would suggest to separate the logic.
This is working example:
Model:
public class ItemsModel
{
private readonly List<DropDownListItem> _items;
public List<DropDownListItem> Items
{ get { return _items; } }
public ItemsModel()
{
this._items = new List<DropDownListItem>();
}
public void addItem(string text, byte value)
{
this._items.Add(new DropDownListItem { Text = text, Value = value });
}
}
public class DropDownListItem
{
public string Text { get; set; }
public byte Value { get; set; }
}
Controller action:
public ActionResult Index()
{
return View();
}
[HttpGET]
public ActionResult ProductDrop()
{
ItemsModel model = new ItemsModel();
model.addItem("Short", 0x24);
model.addItem("Long", 0x32);
return PartialView("ProductDrop", model);
}
And two views:
Index:
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@section scripts
{
<script>
$(document).ready(function() {
$.ajax({
url: "@Url.Action("ProductDrop")",
type: "GET",
datatype: "text",
traditional: true,
async: true,
cache: false
}).done(function(result) {
$(".ddlist").html(result);
});
});
</script>
}
<div class="ddlist"></div>
and PartialView:
@model MvcApplication1.Models.ItemsModel
@Html.DropDownListFor(m=>m.Items, new SelectList(Model.Items, "Value", "Text"))
You can avoid partial view if you use the code without JQuery
p.s. Sorry I didn't take to account that you want to return JSON.
In case with JSON take a look to https://stackoverflow.com/a/5246804/4121714
But I don't see why you want to use helper with JSON (maybe I'm wrong).