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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:24:22+00:00 2026-06-18T17:24:22+00:00

Okay so I am using the MVC framework. I have a view for adding

  • 0

Okay so I am using the MVC framework. I have a view for adding a model. At the moment I am using the default “Create” controller.

I want to be able to create a model with my own variables pre-set. For example the model.UserId I want to set to the users Id. I want some values to be inputed by the user and I want some to be already set. Is there a way I could do something like this

(pseudo code)

model.matchId = 123
model.prediction type = "user input"
add model 

here is my current code below

@using (Html.BeginForm()) {
@Html.ValidationSummary(true)

<fieldset>
    <legend>Predictions</legend>

    <div class="editor-label">
        @Html.LabelFor(model => model.MatchId, "Match")
    </div>
    <div class="editor-field">
        @Html.DropDownList("MatchId", String.Empty)
        @Html.ValidationMessageFor(model => model.MatchId)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.UserId, "User")
    </div>
    <div class="editor-field">
        @Html.DropDownList("UserId", String.Empty)
        @Html.ValidationMessageFor(model => model.UserId)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Type)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Type)
        @Html.ValidationMessageFor(model => model.Type)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Prediction)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Prediction)
        @Html.ValidationMessageFor(model => model.Prediction)
    </div>

    <p>
        <input type="submit" value="Create" />
    </p>
</fieldset>

}

  • 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-18T17:24:24+00:00Added an answer on June 18, 2026 at 5:24 pm

    In the controller, you would set the values on the model before returning it to the View.

    public class HomeController : Controller
        {
            public ActionResult About()
            {
                var model = new MyModel();
                model.SomeId = 123;
                model.SomeOtherProperty = "Hello World";
                return View(model);
            } 
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so I am developing an advanced framework in PHP using MVC and want
I am using spring 3 mvc/security frameworks. I have created a Controller class that
Okay; using the Umbraco CMS I have a xslt menu being generated in the
Okay, so I'm using Rajawali (See: http://www.rozengain.com/blog/2011/08/23/announcing-rajawali-an-opengl-es-2-0-based-3d-framework-for-android/ ) to create a 3D sphere with
Okay, so I'm designing a stand-alone web service (using RestLET as my framework). My
I have an ASP.NET MVC 3 app that is using SQL Server CE 4.0
I develop applet in Eclipse and it runs okay using default in-built Applet Viewer.
In my MVC 4 project, I have a Model like: public class MyModel {
I'm sending an email from my ASP.NET MVC app using the Spark View Engine
Okay so I have a MVC project that auto generates an AccountController AcountModel and

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.