Mega Code Archive

 
Categories / ASP.Net / Development
 

Submitting and displaying form values in ASP NET

<%@ Page Language="vb" %> <html>    <head>       <title>Submitting and displaying form values in ASP.NET</title>    <script runat="server">       Sub Page_Load()          If Request.HttpMethod = "POST" Then             Dim Counter1 As Integer             Dim Keys() As String             Dim FormElements As NameValueCollection             FormElements=Request.Form             Keys = FormElements.AllKeys             For Counter1 = 0 To Keys.GetUpperBound(0)                Response.Write("Form " & Counter1 & " name: " & Keys(Counter1) & "<br>")                Response.Write("Form " & Counter1 & " value: " & FormElements(Counter1) & "<br>")             Next Counter1          End If        End Sub    </script>    </head> <body> <% If Request.HttpMethod = "GET" Then %> <form id="Form1" method="post">    First Name:     <br>    <input type="text" id="txtFName" name="txtFName">    <br>    Last Name:     <br>    <input type="text" id="txtLName" name="txtLName">    <br>    <input type="submit" value="Submit" id="Submit1"> </form> <% End If %> </body> </html>