0

i am system.datamodel.dataannotation for validating my views.

below is my Model for the view.

using System.ComponentModel.DataAnnotations;

    public class LoginVM
{
    [Required(ErrorMessage="Please provide UserName")]
    public string UserName { get; set; }
    public string Password { get; set; }
}

below is my view for Login

<% using (Html.BeginForm())
{ %>
<% Html.ValidationSummary(true); %>
<div style="width: 100%; height: 100%; border-style: none;">
    <fieldset style="border-style: none;">
        <table style="width: 100%; height: 100%; border-style: none;" border="0">
            <tr>
                <td style="height: 100px;" colspan="4">
                </td>
                <td class="editor-label" style="width: 35%; font-size: medium;   vertical-align: top;
                    text-align: justify;">
                    <%: Html.Label("Sign in with your Account Credentials")%><br />
                    <br />
                    <a href='<%= Url.Action("LogOn","Site") %>' class="header-links">Support / Contact Us</a>
                </td>
                <td style="width: 5%;">
                </td>
                <td style="width: 60%; border-left-width: 2px; border-left-color: #E3E3E3; border-left-style: solid;">
                    <table style="border-style: none;" border="0">
                        <tr>
                            <td colspan="3">
                            </td>
                        </tr>
                        <tr style="height: 30px;">
                            <td style="width: 20%;" class="login-display-label">
                                <%: Html.LabelFor(m=>m.UserName,"UserName :") %><br />
                                <br />
                                <%: Html.LabelFor(m=>m.Password,"Password :") %><br />
                                <br />
                            </td>
                            <td style="width: 182px;" colspan="2">
                                <%: Html.TextBoxFor(m=>m.UserName,"UserName :")%><br />
                                <%: Html.ValidationMessageFor(m=>m.UserName) %><br />
                                <%: Html.TextBoxFor(m=>m.Password,"Password :")%><br />
                                <%: Html.ValidationMessageFor(m=>m.Password) %><br />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp
                            </td>
                            <td style="width: 182px;" colspan="3">
                                <input type="button" id="btnSubmit" value="Submit" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </fieldset>
</div>

below is the scripts i have putted on my view as well as my site.master page

   <script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>

i have also checked my web.config for below markup

  <appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>

after lots of effort my validation doesnt occur please help me....

let me known what necessary change i have to make.

thnaks in advance

1
  • remove unnecessary code from question. Commented May 6, 2012 at 12:23

1 Answer 1

1

change javascript Address:

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

and Html Helper

Html.TextBoxFor(m=>m.UserName)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.