By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,685 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,685 IT Pros & Developers. It's quick & easy.

Request.Form not wokring

P: 1
Hi,
I've been trying for days a simple post from a form to another page, and capture a textbox which is passed using a post. I did try using a GET, and it works Okay with a Request.QueryString. But is doesn't work with a Request.Form Any ideas ? (I do this everyday with PHP and Python, but with VB.NET seems I am missing something).

The WebForm1.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication9.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server" method="post" action="Page2.aspx">

<asp:TextBox type="text" name="name" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>

and Page2.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Page2.aspx.vb" Inherits="WebApplication9.Page2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>

<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>

</body>
</html>

and Page2.aspx.vb:
Public Class Page2
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim firstName As String = Request.Form("name")
Response.Write(firstName)
Label1.Text = firstName
End Sub

End Class
Apr 9 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.