Click here to Skip to main content
15,886,077 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
In the old html structure, if one wanted a feedback or any response from the user, normally they add a pretty standard from like put your name, email and comments and we get back to you.
So when the use fills in the name email and comments and clicks the send button the information disappears and the user gets a response that your message has been sent and the user will be contacted or get an answer soon. in the form tag there is like

<form name="Form1" method="Post" action="Some ISP Site ">


where is the information goes which the user has sent ? does it goes like a email message to the site owner ? does it sits in a database under a comments table ? the old days this was handled by some internet service providers address and then either the site owner use to get an email.

I am using an MVC web app where I have a comments form, now what do I need to do that I get the data back which user inputs ?

My forms functionality is perfect, the user puts in name address and comments and he/she gets redirected to a page where it say thanks for your input we will get back to you.

Now the million dollar question where is this data which user put in ?
Posted

1 solution

In my article MVC Basic Site: Step 1 – Multilingual Site Skeleton[^] I am providing a good examples (and source code) of user authentication and registration mechanisms implemented from scratch. So you should see there in AccountControler.Register() how to handle the user registration data that come from Register view.
 
Share this answer
 
Comments
Jahangir Khan 25-Mar-14 16:37pm    
I am looking for solution regarding this in the normal old html form

<FORM method="post" action="http://www.mysite.com/cgi-bin/FormMail.pl">
<input type="hidden" name="recipient" value="webmaster@mysite.com">
<input type="hidden" name="subject" value="From Communication Page">
<input type="hidden" name="redirect" value="http://www.mysite.com/communication.htm">

how do I implment this in MVC
Raul Iloc 26-Mar-14 2:48am    
If you are using MVC in your page you should use razor code in place of <FORM ...> should be: @using (Html.BeginForm()){...} and in place of <input type="hidden"...> you should use: @Html.HiddenFor(...), and so on.
Jahangir Khan 26-Mar-14 3:04am    
You are absloutely right the code is like this ! Sorry the language is Danish, but one can get an idea what is it :
@using(Html.BeginForm())
{
<div> @Html.LabelFor(Model => Model.Navn)</div>
<div> @Html.TextBoxFor(Model => Model.Navn)</div>
<div> @Html.ValidationMessageFor(Model => Model.Navn)</div>

<div> @Html.LabelFor(Model => Model.Email)</div>
<div> @Html.TextBoxFor(Model=> Model.Email)</div>
<div> @Html.ValidationMessageFor(Model => Model.Email)</div>

<div> @Html.LabelFor(Model => Model.Kommentar)</div>
<div> @Html.TextAreaFor(Model => Model.Kommentar) </div>
<div> @Html.ValidationMessageFor(Model => Model.Kommentar)</div>

<button type="submit">Send</button>

}

should I do this after curly
@Html.HiddenFor(m => m.Kommentar, new { Value = "SvarKontakt" })
@ BeginRouteForm(s:http://www.mysite.com/cgi-bin/FormMail.pl)

if you be so kind to advise me about the placeing of the "action" part, where I will recevie the input info from user,I will be ever so greatfull
Raul Iloc 26-Mar-14 3:34am    
You should put your action part like this: @using(Html.BeginForm("YourActionName", "YourControllerName");

You have to implment the method "YourActionName" in your controller and there you should manage the user inputs that will come as param of type "Model".
Raul Iloc 26-Mar-14 4:10am    
Normally your action have to be implemented in your controller class, but if you want to redirect to a specific site you could use it like this: @Html.BeginForm(
null, null, FormMethod.Post, new {@action="http://www.mysite.com/cgi-bin/FormMail.pl"} but this do not solve your problem!
)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900