Tuesday, March 3, 2009

ASP.Net Print Posted Values

Create two web forms, one name posting.aspx and another is posted.aspx, on the posing.aspx place different web controls like text boxes, dropdown list, etc
When finished, open the source view of posting.aspx and set the action property of the form tag to "posted.aspx", this will direct the page to post values to the posted.aspx page. Dont forget to place a submit button on posting.aspx page, so we click to post the values.

Posting.aspx page:
(a). Here you will add all user input controls
(b). place a submit button
(c). Set action property of the form to "posted.aspx"
(d). Set method property of the form to either post of get

Posted.aspx:
Now create the posted.aspx page and simply place the below code in the source of posted.aspx page.

<%For Each skey As String In Me.Request.Form.Keys%>
<%sKey%>=<%Request.Form.Get(sKey)%>
<%Next %>

This code will print out all the posted parameters with the name and values.
Only those parameters will be posted for which value is set or entered by the user.
Now click submit and see the result, you will find list of parameters with there values.

No comments:

Post a Comment