I've got an application that submits a form using method=post. Having a tough time accessing these values in asp.net / c#.
Just to clarify a regular html form submits to test.aspx using post method. in the form-load section of the c# I attempt to query the value.
Ex.
Keeping it simple -
Label2.Text = Request.Form("Text1").ToString();
Text1 is the name of the form element in the submitting form.
----------------------------------------------------------
using example from MS below results in blank string in label1
System.Text.StringBuilder displayValues =
new System.Text.StringBuilder();
System.Collections.Specialized.NameValueCollection
postedValues = Request.Form;
String nextKey;
for (int i = 0; i < postedValues.AllKeys.Length; i++)
{
nextKey = postedValues.AllKeys;
if (nextKey.Substring(0, 2) != "__")
{
displayValues.Append("<br>");
displayValues.Append(nextKey);
displayValues.Append(" = ");
displayValues.Append(postedValues);
}
}
Label1.Text = displayValues.ToString();
}
Just to clarify a regular html form submits to test.aspx using post method. in the form-load section of the c# I attempt to query the value.
Ex.
Keeping it simple -
Label2.Text = Request.Form("Text1").ToString();
Text1 is the name of the form element in the submitting form.
----------------------------------------------------------
using example from MS below results in blank string in label1
System.Text.StringBuilder displayValues =
new System.Text.StringBuilder();
System.Collections.Specialized.NameValueCollection
postedValues = Request.Form;
String nextKey;
for (int i = 0; i < postedValues.AllKeys.Length; i++)
{
nextKey = postedValues.AllKeys;
if (nextKey.Substring(0, 2) != "__")
{
displayValues.Append("<br>");
displayValues.Append(nextKey);
displayValues.Append(" = ");
displayValues.Append(postedValues);
}
}
Label1.Text = displayValues.ToString();
}