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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:42:55+00:00 2026-05-23T14:42:55+00:00

I’ll explain a generic scenario. To explain my problem, I’d request some patience until

  • 0

I’ll explain a generic scenario. To explain my problem, I’d request some patience until I explain how I’ve implemented my Search page. I’ve a [Users] table and an [Address] table based on which I’ve derived a VIEW in SQL – [vw_User_Addr]. I’m using L2S so that I’ll get a strongly typed vw_User_Addr class.

Now I’ve a search page so apparently I’ll derive it from this class like:

<%@ Page Title="User Search" ... Inherits="System.Web.Mvc.ViewPage<MyDAL.vw_User_Addr>" %>

My List action returns a List which I use in the View to form the Grid table. Everything is fine till here. Now I want to implement search on this page. So this is what I found –

  • In Controller during the List Action I create ViewData[“Usr”] = new vw_User_Addr();
  • In my View I do:

    <% MyDAL.vw_User_Addr usr =
    ((MyDAL.vw_User_Addr)(ViewData[“Usr”]));
    %>

  • Then I use this “usr” object to bind my search control like:

    <%= Html.TextBox(“FirstName”,
    usr.FirstName)%>

  • Finally in my HttpPost handler action I object vw_User_Addr like:

    [HttpPost] public ActionResult
    List(vw_User_Addr searchObj){…}

  • I use this searchObj to extract the values user might have populated in the search controls and then I perform search.


So, I hope I explained well. This is how I do my search in MVC2. Here’re my concerns/questions:

  1. When I click on the search image-button I get a postback but it fires a ModelValidation which gives error. Not with all but atleast those which are int (i.e. like Roles dropdown search control) – how to handle that?

  2. After a lot of R&D I’ve settled that I’ve to either do a ModelState.Clear(); or a more complex way to handle this. Is there a better option?

  3. Is there a better way to achieve the search-implementation explained above? Am I using the standard\best way to do search in MVC?

  4. At core-level, can I make L2S understand that this is an SQL-View so its Readonly and all the fields can be NULL – so that the Mr.DefaultModelValidator doesn’t perform such illogical validations?

  5. If 4. is viable can I set the properties of all the fields in the L2S view to be readonly to give it a try?

Thank you for your precious time and review. Pls guide me if I’m not on the track. I believe this is the simplest search-scenario and so it has to be easy. Just need to find the missing links.

  • 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-23T14:42:55+00:00Added an answer on May 23, 2026 at 2:42 pm

    I implemented an ActionFilterAttribute [SkipModelValidation] which avoids/eliminates unwanted model validation for search pages.

    Ref: How to disable validation in a HttpPost action in ASP.NET MVC 3?

    public class SkipModelValidationAttribute : ActionFilterAttribute
        {
            public override void OnActionExecuting(ActionExecutingContext filterContext)
            {
                //Get ModelState
                ModelStateDictionary dict = ((Controller)filterContext.Controller).ModelState;
    
                if (dict != null && !dict.IsValid)
                    dict.Clear();
    
                base.OnActionExecuting(filterContext);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker

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.