I have a model like this
public class Local
{
public int Id { get; set; }
public string Name{ get; set; }
public List<string> Tags{ get; set; }
}
I need a simple view to create a model but I don’t know how to pass a list of comma separated tags from the view to the controller and then save the model with the list of tags. I saw in a similar post a solution that uses text.Split(‘,’) but my problem is that I don’t know how to pass the input text to the create action. I’m using ASP MVC 4. Sorry if this is to basic but I’m new to ASP MVC.
Thanks in advance.
I’m not sure if I understand your question (it’s really vague) but you can just create a ViewModel that has a string property called ‘Tags’ (the comma separated data), you create a form for this ViewModel (you can use Html.EditorForModel), and in your controller simply convert your ViewModel to your entity that has a list of tags by splitting the string into an array.