Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I'm trying use multiple textboxes in mvc view only first one pass the value other all passes null values.

What I have tried:

This One Passes Value

HTML
<label class="col-md-3 control-label">A Title</label>
                                                @Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })


These are Null.
HTML
<label class="col-md-3 control-label">B Title</label>
                                                @Html.TextBoxFor(model => model.A , new {@class = "form-control input-inline input-medium" })

  <label class="col-md-3 control-label">cTitle</label>
                                                @Html.TextBoxFor(model => model.B , new {@class = "form-control input-inline input-medium" })
Posted
Updated 10-Nov-16 22:01pm
v2
Comments
F-ES Sitecore 11-Nov-16 4:12am    
There is nothing wrong with the code so the problem is elsewhere in code you haven't posted. I'm going to assume this is submitted via ajax maybe, or some other important thing is going on that you haven't mentioned. Maybe it's as simple as those null fields are outside the form.

1 solution

You need to use a other model type value.

You now using 3 times model.NpdTitle.

So it will set model.NpdTitle to a value whenever you change 1 of the 3.


<label class="col-md-3 control-label">A Title</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })

<label class="col-md-3 control-label">B Title</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })

<label class="col-md-3 control-label">cTitle</label>
@Html.TextBoxFor(model => model.NpdTitle , new {@class = "form-control input-inline input-medium" })

make npctitel, npbTitle and nptTitle or something simulair
 
Share this answer
 
v2
Comments
T_Sub 11-Nov-16 4:02am    
I have Updated Again
Wessel Beulink 11-Nov-16 4:50am    
Oke, weird. Can you post the posting methode you are using?
You use the default mvc way: using Html.BeginForm
Or are you using javascript/ jquery post methode?
T_Sub 11-Nov-16 5:01am    
thank you very much for your help, i found reason i have used another form inside the
Html.BeginForm. thanks again.!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900