last day (15 days later) » 

7:58 PM
1
A: Pass model from partial view to controller

Erik Philips @ErikPhilips How would I use jQuery to change the form's destination? :) I would change the Action link to a button: @Html.ValidationSummary("", new { @class = "text-danger" }) <div class="form-group"> @Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" }) <div cla...

 
Testing is overrated...Works perfectly! Thanks!
 
That jQuery should be pretty straight forward. Let me know if anything doesn't make sense.
 
Even though I got a break point in the correct ForgotPassword method in the Account controller, the model that gets passed in has one element, email, and this is null. Even though I fill it out. Why would it be passing a model without the entered email address?
 
Are you sure the Partial is contained within the form?
 
Yes, it is there. I have java script to show it on a link click.
 
7:58 PM
In your question, please post the HTML generated by: @Html.TextBoxFor(m => m.Email, new { @class = "form-control" }) and the signature for your AccountController.ForgetPassword(..) method?
 
Hey Erik
I just posted the generated HTML
and thanks for all of your help.
 
Sure no problem
I'll also working so I won't be super fast responding
 
ok thats fine
 
Do you use chrome?
 
Firefox mostly
 
8:08 PM
Can you see the post to the action?
 
is that something Fiddler can do?
 
yeah
 
ok, let me try
 
I haven't used that in a while (since chrome has it built in)
 
The post is:
localhost:49535 / Account / ForgotPassword
(Added spaces so it would show here)
 
8:14 PM
The body of the post?
 
this?
POST http://localhost:49535/Account/ForgotPassword HTTP/1.1
Host: localhost:49535
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:49535/
Cookie: __RequestVerificationToken=UW8ENhygmauhgiBy2vL4KoeAohYE5rZpIU1c3AKvazrSXRO4d5WgXwDJ1CFYSijm8zvpP8EExJ6vV--r7HXcPsmv3Z6PJx6sM5RYOY5z8c41
Connection: keep-alive
 
Ahh see that
__RequestVerificationToken=CaqmR6GVIX7w-iF783hyaWEnm0Htw-AIwMTvK5cWJ-iBd5tZjjEuJZ‌​CDncrvGuiWPei9znt7uECj5aXnLK5XlrvUvpG-JbpdTULyJa4fm6s1&Email=&Password=&Email=mwa‌​rren%40emigra.com
Email is listed twice
The model binder will only bind to the first instance of Email.
Thus the concern on my comment:
or use javascript/ajax to change the forms destination, and submit the form (but be careful because now you have additional form elements that may conflict with each other on the same form).
 
oh.. Email= and Email=[address]
oh.. there is another email element on the page?
sorry
there is
 
8:46 PM
You can hack it with javascript
before the .submit()
oh there is no way to uniquely find the email element
you may want to wrap that partial in
<div class="forgot-password">
/...
</div>
then you can do:
 
I just changed the name in the forgotpassword model to make it different than the other email field on the screen.. it seemed to work
 
$('input[name=email]'.val($('.forgot-password input[name=email]').val())
That is a MUCH better way to do it
 
ok
got it
thanks Erik
 
Have a great day
 

last day (15 days later) »