0

Due to crazyness in this project (Too long a story to get in right now), we need to keep the data in the Model of the form, but not display it on the form on successfull postback, where the form postback was succesfull -

<%= Html.TextBox("FullName", "", new { @class = "required", title = "Full Name is required" })%>

Dosent seem to do the trick - and I cant reset the model in the controller, because on post back we want a message (that appears on the same page) that pretty much says something like "Thankyou for your query regarding XYZ (which is what they entered in one of the text boxes)"

I hope that makes sense.

3 Answers 3

3

Sounds like a duplicate of this question. Reposting my answer here.

Sounds like a job for the PRG (Post Redirect Get) pattern because you don't want the users to refresh the page and have it submit again.

To do this I would put a message or flag in your TempData so that you can inspect that when you redirect back to the original url to then display a message to the user.

HTHs,
Charles

Sign up to request clarification or add additional context in comments.

Comments

0

Try the overload of Html.TextBox that does not take a value:

Html.TextBox("FullName", 
    new { @class = "required", title = "Full Name is required" })

Comments

0

After post you should always redirect to avoid problems with resubmiting the form. If you want to show message, you can use TempData. Just set TempData["ThankYouMessage"] before redirecting and then, if value is set, show the message.

Here you can read about TempData in MVC 2:

http://weblogs.asp.net/jacqueseloff/archive/2009/11/17/tempdata-improvements.aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.