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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:15:07+00:00 2026-05-16T16:15:07+00:00

I am using ASP.NET partial views like in this example <% using (Html.BeginForm()) {

  • 0

I am using ASP.NET partial views like in this example

<% using (Html.BeginForm()) { %>
    <table cellspacing="2" cellpadding="0" border="0" width="100%">
    <tr>
        <td><%= Html.LabelFor(model => model.PersonName)%></td>
        <td>
            <%= Html.TextBoxFor(model => model.PersonName)%>
            <%= Html.ValidationMessageFor(model => model.PersonName, "*")%>
        </td>
    </tr>
    ...
    <tr><td colspan="2"><%= Html.ValidationSummary(false) %></td></tr>
    </table>
<% } %>

I show these partial views in Jquery dialogs calling them using jquery code

$.ajax({
    type: "get",
    dataType: "html",
    url: urlAction,
    data: {},
    success: function(response) {
        $("#panelDetail").html('').html(response).dialog('open');
    }
});

and everything works and make me happy. I am also able to submit the form using jquery ajax and this make me even more happy. 🙂

What is really annoying is that I did not understand where validation occurs because, when it happens, it does a full refresh of the page and close the dialog.

I am sure that somebody can help on this. Anyway….who will be? 🙂

Thanks in advance!

EDIT:

This is the controller action signature with some code in it

[HttpPost]
public ActionResult MyAction(FormCollection form) {
    string foroID = form["ForoId"];
    string foro = form["Foro"];
    string authorityId = form["AuthorityId"];
    string sezione = form["Sezione"];
    ...
}

Do I have to re-create the model class to validate it?

  • 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-16T16:15:08+00:00Added an answer on May 16, 2026 at 4:15 pm

    First of all: if you’re using client validation, than the first check is already on the client side using JavaScript, but your validation would show errors while typing in data.

    Second of all: your data being sent back to controller action is being validated at that particular point as long as your action takes a parameter of the same type as your PartialView has as model type. If this type (class) has data annotations attached to properties, those are being validated. Of course you should as well check for model errors in your action and act accordingly.

    A redirect? If you’d provide some more code of your controller action we could more easily check what’s going on and provide some additional help.

    How did I handle this situation

    I created a special action filter that checks for model state errors and returns 400 to the client with error description. All my Ajax calls handle success as well as error replies and act accordingly.

    Check the code here (question and solution).

    The actual solution

    This solution is based on additional information gotten from comments below

    So after a discussion the problem isn’t actually the full page post-back, but the validation that didn’t happen at all. The reason being that controller action takes a parameter of type FormCollection. MVC framework has no knowledge whatsoever to know how to validate that data, so no validation happens.

    The change you have to do is to change the type of this parameter, to match your strong type view. If your view is of type ViewPage<MyCustomType> then your HttpPost action should most probably have a parameter of the same type.

    In general action type can have parameters of any type. Yes it can have even more parameters. The only restriction being that default model binder will be able to relate posted data to these parameters. This is where you come in. All you have to do is to name your parameters properly and model binder will do the rest.

    If you come across a certain situation where this can’t be done easily, you can always write a custom model binder for a particular type, and it will be completely on you how to parse posted data.

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

Sidebar

Related Questions

I want to use partial views with AJAX calls in ASP.NET MVC, and this
'm using ASP.NET MVC 3 with Razor views. I have a partial view which
How to render partial view in some specific div without using ajax in asp.net
I have an interesting problem when using partial page update in asp.net with scriptmanager
I'm working with ASP.NET MVC 2. I have a bunch of partial views that
I am using ASP.Net MVC. I have a partial view which has a form
ASP .NET MVC 1 I'd like to show a partial view base on a
I am using T4MVC in our ASP.NET MVC project. I have a statement like
Using asp.net MVC3, I have a partial view which requires remote validation. As I
We're building a business application using Microsoft ASP.NET MVC 3. Some views are now

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.