In one of my views I got an INPUT field where I put my cursor and scan a MagCard through a reader. Which result in a series of chars in that box, ending with ENTER (char 13) which I catch via jQuery and post my form to another page to be processed.
Basicly I want the string from the input box to be available in a controller, so I can deal with it using c# functions instead of doing it all client side via javascript.
Getting values to managed code from client code seems to have eluded all guides I have found so far.
Any help appreciated, and the reason for me to POST and not GET is because its filled with special chars, ?'s and spaces which need to be preserved.
Any method will be valued.
@Darin Dimitrov Sorry for me being unclear.
While your suggestion works, and guided me a little towards what I need. (This will be handy to know no matter what.)
As I don't really want a return value, I was trying to post to Home/ProcessScan as action for my form. Then in my controller make this:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ProcessScan(string scanSeek)
{
string myScan = scanSeek;
string name = myScan.Substring(1, 13);
return Redirect("../reservation?name=" + name);
}
And this now works for me. Had to:
* Use the [AcceptVerbs(HttpVerbs.Post)] declaration
* Change my type to ActionResult, instead of void, since redirect need return in front of it
Note: for my redirect I use "../" because this view is not under Home.