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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:54:02+00:00 2026-06-01T08:54:02+00:00

Here’s my situation: I’ve got a number of specialized object types in my application,

  • 0

Here’s my situation: I’ve got a number of specialized object types in my application, and I’m following the standard convention for displaying them with custom templates in the /Shared/DisplayTemplates folder, and editing them with templates in /Shared/EditorTemplates. But I also want to be able to display a custom filter template for each type, so I’d like to add a /Shared/FilterTemplates folder, and implement my own @Html.FilterFor method, so that showing a Filter template is exactly like showing a Display or Editor template.

Does this seem like the best way to handle this situation, or is there a more correct/elegant way to do this in MVC? Thanks in advance.

  • 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-01T08:54:03+00:00Added an answer on June 1, 2026 at 8:54 am

    I’m always using EditorTemplates when data is sent back to server. I assume the user can submit the filter to the server to perform the actual filtering.

    When creating filters I prefer to create a model for the filter like:

    public class UserListFilterModel
    {
        public string Username { get; set; }
        public bool IsEnabled { get; set; }
    }
    

    The view for UserListFilterModel goes into EditorTemplates/UserListFilterModel.ascx.

    And then add it as a property on my view model for the page.

    public class MyPageViewModel
    {
        public UserListFilterModel Filter { get; set; }
    }
    

    Then I add the filter model to the model for the page and displays it like this:

    <%= Html.EditorFor(x => x.Filter)%>
    

    You are probably wrapping the filter in a form to allow the user to submit the values so I think it belongs in EditorTemplates. The users is in fact editing the filter model.

    (If you really want to separate them ing you could use the UIHintAttribute but I wouldn’t)

    Edit: I added some sample code.

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

Sidebar

Related Questions

Here's my situation. I have a DotNetNuke application. I want to link to an
Here is the situation. I am making changes to an application but I do
Here is a scenario: User installs .NET application that you have made. After some
Here I am trying to change the value of the following check box while
Here's my situation. I've noticed that code gets harder to maintain when you keep
Here's the situation, i want to have a user that can enter time on
Here is an object that I'd like to use with ng-repeat, but it's not
Here's the code I'm running. Basically I scrape data, and place them into simple
Here is another spoj problem that asks how to find the number of distinct
Here we have multiple custom query-DSLs that use related grammar. I am creating to

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.