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

The Archive Base Latest Questions

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

Below Scenario, I think I must see the START text in my form when

  • 0

Below Scenario, I think I must see the START text in my form when first loaded.
When I click send data button and submit, I was waiting to see FINISH text in my form.

Buy the START text never changes when I click the button and post the form…

Anybody can tell the problem?

MY CONTROLLER:

namespace MvcApplication1.Controllers
{
    public class BuyController : Controller
    {
        public ActionResult Index(BuyModel model)
        {
            if (Request.HttpMethod == "GET")
            {
                model.Message= "START";
                return View(model);
            }
            else
            {
                BuyModel newModel = new BuyModel();
                newModel.Message= "FINISH";
                    return View(newModel);
            }
        }
    }
}

MY VIEW :

@model MvcApplication1.Models.BuyModel
@using (Html.BeginForm("Index", "Buy", FormMethod.Post))
 {
        @Html.TextBoxFor(s => s.Message)
    <button type="submit" >Send</button>
 }              

MY MODEL:

public class BuyModel
{
    public string Message { get; set; }
}
  • 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:03:30+00:00Added an answer on May 30, 2026 at 7:03 am
                public class BuyController : Controller
                {
                    public ActionResult Index()
                    {
                        BuyModel model = new BuyModel();
                        model.Message= "START";
                        return View(model);
                    }
    
                    [HttpPost]
                    public ActionResult Index(BuyModel model)
                    {
                        model = new BuyModel();
                        model.Message= "FINISH";
    
                        ModelState.Clear();  // the fix
    
                        return View(model);
                    }
                }
    

    View:

    @model MvcApplication1.Models.BuyModel
    @using (Html.BeginForm("Index", "Buy"))
     {
            @Html.TextBoxFor(s => s.Message)
        <button type="submit" >Send</button>
     }   
    

    Your issue is because your original code, that Action Method will only be executed as an HTTP GET request. ASP.NET MVC allows you to specify a post with the [HttpPost] attribute (see above code).

    I’m not sure what you are getting at with your POST desired-behavior. It seems like you are just wiping out whatever form values are pushed on the POST. So modify my above code accordingly, but it should give you the general idea.

    Edit: it seems to be that the text box is retaining its value after the POST. It’s not just with "START", but if you type anything into that text box and hit submit, you’ll have a POST with the exact same text in the text box that was there when you submitted the form.

    Edit Edit: see the changed code. Call ModelState.Clear() in your POST action method and you’ll have the right value reflected.

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

Sidebar

Related Questions

I was expecting the below scenario common, but couldn't find much help online. I
I was wondering if the below scenario will work? I am having trouble with
How can I check the duplicate signatures before adding. In the below scenario, I
Please help with below mentioned scenario-> I am having wanna display values from 1
I'm looking for example of how I would solve the scenario below: Imagine my
Please suggest me the best authentication way to implement in the scenario mentioned below:
My scenario is to replace the below string /dboracle/orabase/product/10.2.0 to /dboracle/orabase/product/11.2.0.2_org Ksh contains following
Scenario : Default.aspx is as below. <%@ Page MasterPageFile=~/StandardLayout.master Language=C# CodeFile=Default.aspx.cs Inherits=_Default %> <%@
Hey all. Here is the scenario. I have the below code, and I'm needing
Scenario: I have a fairly generic table (Data), that has an identity column. The

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.