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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:14:25+00:00 2026-05-30T07:14:25+00:00

Well, I need to create two questionnaires that are almost equals. The difference are

  • 0

Well, I need to create two questionnaires that are almost equals. The difference are that one have a question more than the other. So I created a class with only the ID (to persistence) to be the base class for both:

public class BaseQuizzClass{
    public int ID {get;set;}
} 

And then I created the classes, with almost the same names for the variables ( I thought that it could help using razor):

public class Quizz1 : BaseQuizzClass{

   [Display(Name="QuestionHere")]
   public string q1 {get;set;}

   [Display(Name="QuestionHere")]
   public string q2 {get;set;}

   ...

   [Display(Name="QuestionHere")]
   public string q9 {get;set;}
}

public class Quizz2 : BaseQuizzClass{
   [Display(Name="QuestionHere")]
   public string q1 {get;set;}

   [Display(Name="QuestionHere")]
   public string q2 {get;set;}

   ...

   [Display(Name="QuestionHere")]
   public string q9 {get;set;}

   [Display(Name="QuestionHere")]
   public string q10 {get;set;}
}

Then I created a View using the BaseQuizzClass as model, so I could pass an child class as parameter toit. But I don’t know how to access the childs class attributes.

OBS.: Each question has your own text, defined in the Display annotation.

There’s any way to do what I want? (I’m not pretty sure if I was clear)

  • 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-30T07:14:26+00:00Added an answer on May 30, 2026 at 7:14 am

    I would probably switch the model up a bit:

    public class QuestionClass
    {
      public String Question { get; set; }
    
      public String Answer { get; set; }
    }
    
    public class QuizzClass
    {
      public Int32 ID { get; set; }
    
      [UIHint("Question")]
      public IList<QuestionClass> Questions { get; set; }
    }
    

    Then create a view for the question, and instead of using the [DisplayAttribute] using the “key/value” setup of the object.

    // ~/Views/_controller_/_action_.cshtml
    @model QuizzClass
    
    @using (Html.BeginForm())
    {
      for (var q = 0; q < Model.Questions.Length; q++)
      {
        // ~/Views/Shared/EditorTemplates/Question.cshtml
        @Html.EditorFor(x => Model.Questions[q]);
      }
    }
    

    It just appears over-kill to have that much similarity, yet explicitly calling out each question in your “different” objects.

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

Sidebar

Related Questions

I have one main application which launch two other process's, i just need to
I have two tables and I need to create a view. The tables are:
I have multiple reports that take the same parameters. Need to create a master
Well i need to make it so any user can have a foo.com/username in
I need a JavaScript library that supports Ajax as well as help me in
I need to create a porting software that will convert Java code to C#
Problem I'm trying to create an CUDA application that is well integrated with .net.
I have two set of folders that have files with the same filenames and
Suppose I have a simple MySQL table that looks like this: CREATE TABLE `my_table`
I have two tables. Lets say tblA and tblB. I need to insert a

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.