Hi everyone, I'm having trouble passing a parameter in my @Html.TextBoxFor(model => model.User.UserName, new { htmlAttributes = new { @class = "form-control" } }).
Because I pass the parameter and send it to a pdf report. Only do this: @Html.TextBox("parametroExemplo", null, new { @class = "form-control" }), but the problem when I do this I can not save in my bank.
Do you mean you can't save model.User.UserName in your model
bank?
If so,when you submit form,it will jump to httppost action,like:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(bank bankmodel)//don't forget set model parameter,it will receive model information
{
if (ModelState.IsValid)
{
db.banks.Add(bank);
db.SaveChanges();
return RedirectToAction("Index");
}
...
return View(bankmodel);
}
If you have any questions,please post more details: your models,view and controller.
Best Regards.
Yuki Tao
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
1 Post
Pass parameters in @Html.TextBoxFor(model => model.User.UserName, new { htmlAttributes = new { @c...
Oct 16, 2018 01:47 PM|sigridslima|LINK
Hi everyone, I'm having trouble passing a parameter in my @Html.TextBoxFor(model => model.User.UserName, new { htmlAttributes = new { @class = "form-control" } }).
Because I pass the parameter and send it to a pdf report. Only do this: @Html.TextBox("parametroExemplo", null, new { @class = "form-control" }), but the problem when I do this I can not save in my bank.
Any suggestion
Contributor
3710 Points
1431 Posts
Re: Pass parameters in @Html.TextBoxFor(model => model.User.UserName, new { htmlAttributes = new...
Oct 17, 2018 06:53 AM|Yuki Tao|LINK
Hi sigridslima,
Do you mean you can't save model.User.UserName in your model bank?
If so,when you submit form,it will jump to httppost action,like:
[HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(bank bankmodel)//don't forget set model parameter,it will receive model information { if (ModelState.IsValid) { db.banks.Add(bank); db.SaveChanges(); return RedirectToAction("Index"); } ... return View(bankmodel); }
If you have any questions,please post more details: your models,view and controller.
Best Regards.
Yuki Tao
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.