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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:56:40+00:00 2026-06-16T03:56:40+00:00

I’ve been working with WebMatrix lately and I’ve been wondering if I can inject

  • 0

I’ve been working with WebMatrix lately and I’ve been wondering if I can inject data into objects.

I used to work with Struts2 and when if you’re familiar with it, if you had an input like <s:textfield name="model.property" .../> the value inserted into that textfield would be injected into the model object or the value in the model object would be injected into the textfield when the page is loaded (and that depends on the logic handled into the web page).

So far in WebMatrix, I’ve seen this type of data injection value="@Request.QueryString["searchGenre"]" where you can access the value from a variable inside Razor code and asign it to a html control, but can it be done in reverse? Can I place a reference to an object in Razor code inside a html control and inject a value into the object when I submit the page?

I know I can access to the query string values inside the request, but I want to know if this approach can be done.

So can it be done? Or there’s a different approach I can take? I want to agilize my coding time so I’m open to suggestions.

Thanks for any help.

  • 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-16T03:56:41+00:00Added an answer on June 16, 2026 at 3:56 am

    Yes, you can provide any default value you like to an HTML form control. The convention is to set the value to the corresponding Request.Form or QueryString value so that if the form fails validation, the values provided by the user are persisted:

    <input type="text" name="color" value="@Request["color"]" />
    

    However, you could set that to a default value, and reset it in the event that the form is posted so that you pick up whatever the user provided:

    @{
        var color = Request["color"].IsEmpty() ? "Red" : Request["color"];
    }
    <input type="text" name="color" value="@color" />
    

    Or, if you want to use the Html Helpers for forms for a more “agile” feel:

    @{
        var color = Request["color"].IsEmpty() ? "Red" : Request["color"];
    }
    @Html.TextBox("color", color)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I want to construct a data frame in an Rcpp function, but when I

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.