Wednesday, March 21, 2012

passing a value from html to aspx

i want to pass a value from a html page to a aspx page

below is the html code and aspx... what am i doing wrong..nothing shows up in aspx

<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>First name</title></head><body><form id="Form1" method="post" action="Receive.aspx" >First name: <input type="text" name="firstname" value ="test"><br><input type="submit" value="Submit" /> </form></body></html>

<%@dotnet.itags.org. Language="vb" Debug="True"%><SCRIPT Runat="Server">Sub Page_Loaddim holdthis as string holdthis = Request.QueryString("firstname") Response.Write(holdthis)End Sub</SCRIPT>

in the script instead of request.querystring, write request.form("firstname")

and it should be fine.


First of all, you are using post in the form, that means you have to use Request.Form("firstname") instead of Request.Querystring("firstname").

Second, try using a label on your aspx page to show the first name.

<!-- HTML Page page1.html -->
 <html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>First name</title>
</head>
<body>
<form id="Form1" method="post" action="Receive.aspx" >
First name:
<input type="text" name="firstname" value ="test">
<br>
<input type="submit" value="Submit" />
</form>
</body>
</html
<!-- asp.net page Receive.aspx -->
<%@. Language="vb" Debug="True"%
<html>
<head>
<title>Capture html form variables</title>
<SCRIPT Runat="Server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dim holdthis as string
holdthis = Request.Form("firstname")
lblFirstName.Text = holdthis
End Sub</SCRIPT></head><body><form name="form1" runat="server">
<asp:Label id="lblFirstName" runat="Server" />
</form>
</body>
</html>

0 comments:

Post a Comment