Click here to Skip to main content
15,900,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a login page in my MVC 3 application.

It is working fine, when I did not give anything inside @Html.BeginForm()

But if I call the page 'PlanMyTravel' using @Html.BeginForm(new {action = "PlanMyTravel"}),
it is doing only client side validations, but not doing server side validations.

It's not checking for password match.

Here is my code. Please help

@model MvcDemo.Models.LogOnModel

    ViewBag.Title = "Log On";

<h2>Log On</h2>
    Please enter your username and password. @Html.ActionLink("Register", "Register") if you don't have an account.

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")

@using (Html.BeginForm(new {action = "PlanMyTravel"}))
            <legend>Account Information</legend>

            <div class="editor-label">
                @Html.LabelFor(m => m.UserName)
            <div class="editor-field">
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)

            <div class="editor-label">
                @Html.LabelFor(m => m.Password)
            <div class="editor-field">
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)

            <div class="editor-label">
                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe)

                <input type="submit" value="Log On" />
Jameel VM 5-Aug-13 10:22am    
did you done any server side validation for password match?
srmohanr 6-Aug-13 6:41am    
Yes, I have server side validations. And it was working fine before I gave 'new {action = "PlanMyTravel"}'

1 solution

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