I have the following HTML Code
<%@ Page Language="C#" %>
<html>
<head>
<title></title>
</head>
<body>
<form id="frmSystem" method="post" action="target.aspx">
<input id="txtTextField" type="text" />
<input id="btnPost" value="Submit" onclick="javascript:frmSystem.submit();" type="button" />
</form>
</body>
</html>
The target Page is coming up but the form that it is receiving is empty. I have a break point on my target.aspx page and while I can see a form, it's keys are empty and Request["txtTextField"] gives me nothing.
Any clue why?
If you are using ASP.NET MVC, the input names need to be set with the "name" attribute rather than "id".
You probably reset the form value in event handlers (such as page_load).
If you are using ASP.NET 4.5 like me, use below hints
more resources with more detail that was useful to me
Another option is to capture your Request.Form[] data in Application_BeginRequest on the Global.asax.cs:
The problem is that the form data is lost on the automatic redirect which is applied by friendlyUrls - if you store that data as something other than form data, it is unnecessary to turn off friendlyUrls or set AutoRedirectMode to RedirectMode.Off.