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

  • SEARCH
  • Home
  • 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 8030409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:45:32+00:00 2026-06-05T00:45:32+00:00

I use ASP.NET MVC 2, with Visual Studio 2008 and my view is strongly-typed.

  • 0

I use ASP.NET MVC 2, with Visual Studio 2008 and my view is strongly-typed. The validation using ValidationAnnotation works.
What I’m trying to find is how to launch the validation when opening the form. When it opens the model has error, but error doesn’t show up. When I press the submit button, the controller validates the model and return to the form.

Public Function EditVente(ByVal pNoEnreg As Integer) As ActionResult
            Dim dossierVente As VenteDansMedianePlus = model.Helper.selectDossierVente(pNoEnreg)

        Return View(dossierVente)
    End Function

    Public Function enregistrerVente(ByVal pVente As VenteDansMedianePlus) As ActionResult
        If ModelState.IsValid Then
            model.Helper.updateDossierVente(pVente)
            Return RedirectToAction("EditVente", "A009P003", New With {Key .pNoEnreg = pVente.noEnreg})
        Else
            Return View("EditVente", pVente)
        End If

    End Function

I try to put ModelState.IsValid in the editVente function, but it doesn’t work.

My question is how to launch the model validation before returning the view, so the view has the error message.

  • 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-06-05T00:45:33+00:00Added an answer on June 5, 2026 at 12:45 am

    I think you’re looking for the TryUpdateModel-method. You can call this method on your controller and pass in your model: (Sorry, I’m a C# developer, hope this is correct)

    Public Function EditVente(ByVal pNoEnreg As Integer) As ActionResult
         Dim dossierVente As VenteDansMedianePlus = model.Helper.selectDossierVente(pNoEnreg)
    
         'Update the validation
         TryUpdateModel(dossierVente)
    
         Return View(dossierVente)
    End Function
    

    For more information, check this SO post: When and why do you use TryUpdateModel in asp.net mvc 2?

    Edit

    The TryUpdateModel-method works about the same as the UpdateModel-method, except that UpdateModel throws errors when the validation fails, where TryUpdateModel doesn’t.

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

Sidebar

Related Questions

Hello I'm using visual studio 2008 with asp.net mvc 2. I need anti xss
To begin with: Using Entity Framework v4.0. ASP.NET MVC 2.0. Visual Studio 2010. I
I create a ASP.net MVC 4 project by using Visual Studio 2010 IDE. I
I am wrapping up an application using ASP.NET in Visual Studio 2008. I am
I've recently begun doing ASP.NET MVC work with others using Visual Studio. While MonoDevelop
Here's the situation: ASP.NET MVC 3 application using Razor as the view engine. Works
I am creating an asp.net mvc 3 app in Visual Studio 2010. Im trying
I'm using MVC 2, Visual Studio 2008, ADO.NET Entity Framework, and previously my database
I am attempting to use ASP.NET MVC 4 beta together with JSON.NET. I'm using
I was trying to use RoR or ASP.NET MVC but at my first impression

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.