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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:55:13+00:00 2026-06-06T15:55:13+00:00

I have this code in mvc 3 razor @using (Html.BeginForm(MyAction, MyController)) { <input type=text

  • 0

I have this code in mvc 3 razor

@using (Html.BeginForm("MyAction", "MyController"))
{
    <input type="text" id="txt" name="txt"/>          
    <input type="image" src="image.gif" alt="" />
}   

in controller I have this code

[HttpPost]
public ActionResult MyAction(string text)
{
    //TODO something with text and return value...
}

now, how to send a new value, for exemple id to Action result??? Thanks

  • 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-06T15:55:15+00:00Added an answer on June 6, 2026 at 3:55 pm

    You use a view model:

    public class MyViewModel
    {
        public string Text { get; set; }
    
        // some other properties that you want to work with in your view ...
    }
    

    and then pass this view model to the view:

    public ActionResult MyAction()
    {
        var model = new MyViewModel();
        model.Text = "foo bar";
        return View(model);
    }
    
    [HttpPost]
    public ActionResult MyAction(MyViewModel model)
    {
        // remove the Text property from the ModelState if you intend
        // to modify it in the POST controller action or HTML helpers will
        // use the old value
        ModelState.Remove("Text");
        model.Text = "some new value";
        return View(model);
    }
    

    and then the view is strongly typed to this model:

    @model MyViewModel
    
    @using (Html.BeginForm("MyAction", "MyController"))
    {
        @Html.EditorFor(x => x.Text)
        <input type="image" src="image.gif" alt="" />
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like in MVC (I am using MVC c# using razor): @Html.ActionLink(Edit,
MVC 3 VB.NET applicaiton... Using express checkout with html razor view. I have tried
This is a beginner level question for asp.net MVC I have the following code
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
I have this code: ie1.link(:text, /Exception:/) It is producing an error message which I
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
I am using ASP.NET MVC 3 with the Razor view engine . I have
I am using MVC 3 with Razor. I can't figure out how to code
I have a telerik mvc grid in a Razor view. I am using custom
I am using s#arp architecture 2.0 with asp.net mvc 3.0. The razor code in

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.