Through an input field the color “green” is submitted.
Now, it takes requesting it.
In PHP it would be $_POST['color'].
I have thought it through, and have gotten it to this code:
The Example:
The Request for the ColorName – with VB.NET 2012 MVC 4:
Public Class ColorPrintOutSubmitClassController
Inherits System.Web.Mvc.Controller
' This method will handle GET
Function PrintOutPage() As ActionResult
Return View("PrintOutPage")
End Function
' This method will handle POST
<HttpPost>
Function ColorPrintOut() As ActionResult
' Do something
Response.Write("You submitted the color: " & Request.QueryString("ColorName") & "<br />")
Return View()
End Function
End Class
The HTML:
<form action="" method="post">
<input type="text" name="ColorName" />
<input type="submit" name="ColorName_SubmitButton" value="Print It Out!" />
</form>
The Questions:
The problem in this attempt is that the color name does not get printed out, as wanted.
- Could the problem be rather on
Reponse.Write, orRequest.QueryString? - How does get the part which is to handle the
GET–"invoked"?
Invoked = to put into effect or operation
(Source: The Merriam-Webster Dictionary)
It is not a QueryString, it is the POST itself. In C# it would just be:
So maybe just (not sure, don’t know VB):
But a better way to do this would be to actually bind to a MVC Model