0

My domain model has property Keywords of type string. Inside database is represented as comma separated value.

On mvc view page I'm collecting user entered keywords as every keyword inside separated textbox which will be replaced into one string value with commas between.

So I tried on inserting new record to collect keywords like this

<div class="editor-field">
    @Html.TextBox(@Model.Keywords, "")
</div>

but on http post controller action this property (Keywords) is empty? What I'm doing wrong here?

1 Answer 1

2

You need to define a form for it.

For instance:

@using (Html.BeginForm("YourControllerAction", "YourControllerName", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<fieldset>
<div class="editor-field">
    @Html.TextBox(@Model.Keywords, "")
</div>
<input type="submit" value="Submit"/> 
</fieldset>
}
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.