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 4544280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:38:59+00:00 2026-05-21T15:38:59+00:00

I am working on an ASP.NET MVC 2 application and am struggling to get

  • 0

I am working on an ASP.NET MVC 2 application and am struggling to get the desired behavior from a dialog window in one of my pages. Think of it as something like the “Add New Item” window in Visual Studio.

When the user clicks a button on the main page, I use the jQuery dialog plug in to display a partial view containing a form. The partial view is strongly-type with DataAnotations used in the Model class to define validation rules. When the user submits the form with valid data, I navigate to another page.

Here are my problems:

  1. Submitting the “out-of-the-box” form (no extra code) messes everything up because returning the view back to the client sends it as the main page and no longer a partial view. This is great when I want to navigate away and use one of the RedirectXYZ overloads in my Action method. But when I want to return just the partial back to display validation errors, this is a major problem.
     
  2. Validation. I’d like to be able to provide the user with feedback when required fields are missing, etc. Using DataAnnotations means that I have to be able to post the page back to the server, check ModelState.IsValid and return the same view if false. As I said in the first bullet, this doesn’t work with partial views. And, while I can enable AJAX validation support by including the MicrosoftXYZ.js files, they aren’t tied into the submit button of the jQuery dialog so being invalid doesn’t prevent submission. (Plus, I don’t want to fix jQuery and AJAX code, if possible).
     

I tried enabling AJAX posting of the form (using the jQuery forms plugin) but without jQuery validation working with DataAnnotations, I am back to square one (plus I’d have to figure out how to redirect the page on a successful submission).

I can’t be the first person to try and display a partial view containing a form in a jQuery dialog that requires validation. Any helps is greatly appreciated as I’ve lost a full day trying to find a solution.

  • 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-21T15:38:59+00:00Added an answer on May 21, 2026 at 3:38 pm

    Because you’re using Javascript popups and sending data to server I suggest you use Ajax. So it will work as expected. If a user clicks Save it would be normal, that your popup form is submitted and saved and closed on the client (and most likely refresh the main page where popup came up).

    Validation

    Anyway. This blog post won’t completely answer your question, but it will make it possible for you to handle model validation errors while using Ajax requests more appropriate. It explains the problem into great detail and provides the code you can use as is.

    Redirection

    Regarding HTTP redirects it’s a bit more complicated since browsers do these things in different ways. Anyway. A different stackoverflow question will try to answer this.

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

Sidebar

Related Questions

I am working with an ASP.NET MVC application. I have one master page having
I am working on an ASP.NET MVC application and using jQuery. I understand from
I am working on asp.net MVC 3 application. One home page of the application,
I'm working on an ASP.NET MVC 3 application. I primarily come from a ASP.NET
I have a asp.net mvc application and am trying to get custom errors working
I'm working on an asp.net MVC 3 application which is using Data Models from
I am working on an ASP.NET MVC application. For some reason, everytime I think
I am working on an asp.net MVC 3 application. I have a C# function
I'm currently working on an Asp.net MVC Web application. In my solution, there're two
I'm working in an ASP.NET 3.5 MVC application where i've got a view with

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.