I am having some troubles with my MVC application
I have created custom binders and they are working for everything except my list of QueryTags
public class QueryTag
{
[Key]
public int QueryTagId { get; set; }
public string TagName { get; set; }
public bool IsChecked { get; set; }
}
In my Binder
string tagName;
int index = 0;
List<QueryTag> tagList = new List<QueryTag>();
while (!string.IsNullOrEmpty(tagName = request.Form["QueryTags[" + (index++) + "].TagName"]))
{
tagList.Add(new QueryTag()
{
QueryTagId = int.Parse(request["QueryTags[" + (index) + "].QueryTagId"]),
TagName = tagName,
IsChecked = request["QueryTags[" + (index) + "].IsChecked"] == "ture,false"
});
}
if (tagList.Count == 0)
{
bindingContext.ModelState.AddModelError("QueryTags[0]", "Something went wrong with the query tags");
}
else
{
model.QueryTags = tagList;
}
and I am using a view with a jquery popup modal like so:
<input type="button" value="Add Tags" id="QueryTagOpener" /> <div id="QueryTagPopup" title="Query Tags"> <div style="width: 25%; float: left"> @for (int i = 0; i < Model.QueryTags.Count(); ++i) { <div class="editor-field"> @Html.DisplayFor(model => model.QueryTags[i].TagName) </div> <div> @Html.EditorFor(model => model.QueryTags[i].IsChecked) </div> } </div> </div>
The request.Form["QueryTags[" + (index++) + "].TagName"] is always null.
I am assuming it has something to do with the jquery popup but I have tried implementing the view like I am for other properties that work with no luck.
I am sure it is something simple but have been bouncing around the internet for hours banging my head and can't figure it out.
Any help would be appreciated.