开发者

after return PartialView() Url.Actionlink("Action", "Controller"), the Controller is lost

Well the Question is related to a problem I posted before (ASP.NET MVC partial view does not call my Action). In practice I've a partial view which contains a Form, after submitting the Form the Controller returns t开发者_Go百科he Partial View.

Well the Problem is if I reload the page which contains the partial view the function <%= Url.Action("ChangePassword", "Account") %> returns "Account/ChangePassword", if I submit the form and the partial is returned by the controller.

Using return PartialView() the function <%= Url.Action("ChangePassword", "Account") %> returns only "ChangePassword".

Any Idea because?

The View looks like:

<form action="<%= Url.Action("ChangePassword", "Account") %>" method="post" id="jform"> 
    <div> 
        <fieldset> 
            <legend>Account Information</legend> 
            <p> 
                <label for="currentPassword">Current password:</label> 
                <%= Html.Password("currentPassword") %> 
                <%= Html.ValidationMessage("currentPassword") %> 
            </p> 
            <p> 
                <label for="newPassword">New password:</label> 
                <%= Html.Password("newPassword") %> 
                <%= Html.ValidationMessage("newPassword") %> 
            </p> 
            <p> 
                <label for="confirmPassword">Confirm new password:</label> 
                <%= Html.Password("confirmPassword") %> 
                <%= Html.ValidationMessage("confirmPassword") %> 
            </p> 
            <p> 
                <input type="submit" value="Change Password" /> 
            </p> 
        </fieldset> 
    </div> 
</form> 
</div> 

<script> 
    $(function() { 
        $('#jform').submit(function() { 
            $('#jform').ajaxSubmit({ target: '#FmChangePassword' }); return false; 
        }); 
    }); 
</script> 

Part of the Controller:

    if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) 
    { 
        return PartialView(ViewData);                 
    } 


Try using Html.BeginForm

http://msdn.microsoft.com/en-us/library/dd492714(v=VS.90).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜