Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 888963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:29:26+00:00 2026-05-15T13:29:26+00:00

I’ve got the following View <% Using Html.BeginForm()%> <%: Html.ValidationSummary(True) %> <div class=displayright> <h3>

  • 0

I’ve got the following View

<% Using Html.BeginForm()%>
<%: Html.ValidationSummary(True) %>
<div class="displayright">
    <h3>
        <%: Html.LabelFor(Function(model) model.About) %></h3>
    <noscript>
        <h3>
            Please use
            <%: Html.ActionLink("Markdown", "Markdown", "About")%>
            to style your input.</h3>
    </noscript>
    <%: Html.TextAreaFor(Function(model) model.About, 5, 5, New With {.class = "user-edit-textarea"})%>
    <div class="wmd-preview">
    </div>
</div>
<%--end left display area--%>
<%--middle display area--%>
<div class="displaymiddle">
    <h3>
        Urban Now User</h3>
    <table width="340">
        <tr>
            <td>
                <%= Html.ValidationSummary("Oops, please correct the errors...") %>
                <%: Html.LabelFor(Function(model) model.UserName)%></td>
            <td class="full-width">
                <%: Html.TextBoxFor(Function(model) model.UserName) %>
                <%: Html.ValidationMessageFor(Function(model) model.UserName) %>
            </td>
        </tr>
        <tr>
            <td>
                <%: Html.LabelFor(Function(model) model.WebSite)%></td>
            <td>
                <%: Html.TextBoxFor(Function(model) model.WebSite) %>
                <%: Html.ValidationMessageFor(Function(model) model.WebSite) %><br />
                <span class="fineprint">http://www.example.com</span> </td>
        </tr>
        <tr>
            <td>
                <%= Html.LabelFor(Function(model) model.BirthDate)%>
            </td>
            <td>
                <%: Html.EditorFor(Function(model) model.BirthDate)%>
                <%: Html.ValidationMessageFor(Function(model) model.BirthDate) %><br />
                <span class="fineprint">never displayed, used to show age.<br />
                    MM/DD/YYYY</span> </td>
        </tr>
        <tr>
            <td>
                <%: Html.LabelFor(Function(model) model.Email)%>
            </td>
            <td>
                <%: Html.TextBoxFor(Function(model) model.Email) %>
                <%: Html.ValidationMessageFor(Function(model) model.Email) %><br />
                <span class="fineprint">never displayed, used for gravatar, optional notifications</span> </td>
        </tr>
        <tr>
            <td>
                <%: Html.LabelFor(Function(model) model.RegionID) %></td>
            <td>
                <%: Html.TextBoxFor(Function(model) model.RegionID) %>
                <%: Html.ValidationMessageFor(Function(model) model.RegionID) %></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="submit" value="Save Profile" />
                <input type="button" id="cancel" name="cancel" value="Cancel" onclick="location.href='<%: Url.Action("Details", "Users", New With {.id = model.ID, .slug = model.UserName})%>'">
            </td>
        </tr>
    </table>
</div>
<%--end middle display area--%>
<% End Using%>

And I’m using this in my controller:

<AcceptVerbs(HttpVerbs.Get)> _
Function Edit(ByVal id As Integer) As ActionResult
    Dim user As Domain.User = UserService.GetUserByID(id)
    Return View(user)
End Function

<AcceptVerbs(HttpVerbs.Post)> _
Function Edit(ByVal id As Integer, ByVal collection As FormCollection) As ActionResult
    If ModelState.IsValid Then
        Return RedirectToAction("Edit", "Users", New With {.id = 1, .slug = "its valid"})
    End If
End Function

And finally I have my MetaData as follows:

<MetadataType(GetType(UserMetaData))> _
Partial Public Class User : End Class

Public Class UserMetaData

    <DisplayName("name")> _
    <Required(ErrorMessage:="Username is required.")> _
    <StringLength(30, ErrorMessage:="Username cannot exceed 30 characters.")> _
    Public Property UserName As String

    <DisplayName("email")> _
    <StringLength(50, ErrorMessage:="Email Address cannot exceed 50 characters.")> _
    <RegularExpression("^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9+)*\\.([a-z]{2,4})$", ErrorMessage:="Not a valid email address.")> _
    Public Property Email As String

    <DisplayName("website")> _
    <StringLength(256, ErrorMessage:="Web Address cannot exceed 256 characters.")> _
    <RegularExpression("^http(s?)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$", ErrorMessage:="Not a valid website address")> _
    Public Property WebSite As String

    <DisplayName("about")> _
    <StringLength(4000, ErrorMessage:="Profile cannot exceed 4000 characters.")> _
    Public Property About As String

    <DisplayName("region")> _
    <Required(ErrorMessage:="Region is required.")> _
    Public Property RegionID As Integer

    <DisplayName("birthdate")> _
    <DisplayFormat(ApplyFormatInEditMode:=True, ConvertEmptyStringToNull:=True, DataFormatString:="{0:MM/dd/yyyy}")> _
    Public Property BirthDate As DateTime
End Class

The problem is that when I submit a blank form back to the controller, I get redirected to the “its valid” page, meaning that the form passed validation.

What might I be doing wrong?

Update:
Ok so changing the bit in my controller is now redirecting me to the “invalid” page

<AcceptVerbs(HttpVerbs.Post)> _
Function Edit(ByVal user As Domain.User) As ActionResult
    Dim id As Integer = Url.RequestContext.RouteData.Values("id")
    If Not ModelState.IsValid Then
        Return RedirectToAction("Edit", "Users", New With { .id = id, .slug = "invalid" })
    End If

    Return RedirectToAction("Details", "Users", New With { .id = id })
End Function

However I’m not getting any highlighting.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:29:26+00:00Added an answer on May 15, 2026 at 1:29 pm

    Eureka, I finally dug up the solution. It was an issue with my Controller.

    Here’s the code

    <AcceptVerbs(HttpVerbs.Post)> _
    Function Edit(ByVal user As Domain.User) As ActionResult
        Dim id As Integer = Url.RequestContext.RouteData.Values("id")
        If ModelState.IsValid Then
            Return RedirectToAction("Details", "Users", New With {.id = id})
        Else
            Return View(user)
        End If
    End Function
    

    The issue was that initially I didn’t have a Domain.User parameter being passed to the Controller ActionResult. Then after my edit, I discovered that if it was INVALID, that I needed to pass that user back to the View in order to see highlighting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 464k
  • Answers 464k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Option One Use the Substitution control or API on your… May 16, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer From http://www.c-faq.com/malloc/realloc.html If realloc cannot find enough space at all,… May 16, 2026 at 12:56 am
  • Editorial Team
    Editorial Team added an answer Hey i came up with a Workaround myself now. To… May 16, 2026 at 12:56 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.