Trying to retrieve posted data from HTML form into C# page.
However I am receiving this error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: 'Ass2.CarPage' is not allowed here because it does not extend class 'System.Web.UI.Page'.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CarPage.aspx.cs" Inherits="Ass2.CarPage"%>
Line 2:
Line 3:
HTML Code:
<!--Car Search Form-->
<div id="Search_Form">
<form name="Car Search" action="CarPage.aspx" method="post">
<h1 align="center">Search For A Car Now: </h1>
<h2 align="center">
<select name="Car">
<option value="Volvo">Volvo</option>
<option value="Ford">Ford</option>
<option value="Mercedes">Mercedes</option>
<option value="Audi">Audi</option>
<option value="Vauxhall">Vauxhall</option>
</select>
<h1 align="center">
<input type="Submit" value="Submit">
</h1>
</form>
</div>
C# Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CarPage.aspx.cs" Inherits="Ass2.CarPage"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<%
if (Request.Form["Car"] == "Volvo")
{
Response.Redirect("VolvoHomepage.html");
}
if (Request.Form["Car"] == "Ford")
{
Response.Redirect("FordHomepage.html");
}
if (Request.Form["Car"] == "Mercedes")
{
Response.Redirect("MercedesHomepage.html");
}
if (Request.Form["Car"] == "Audi")
{
Response.Redirect("AudiHomepage.html");
}
if (Request.Form["Car"] == "Vauxhall")
{
Response.Redirect("VauxhallHomepage.html");
}
%>
</body>
</html>
ASPX.CS Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
C#
andVB
code on the same page. Remove theEnd If
. – VDWWDWebApplication
toAss2
and the class name fromWebForm1
toCarPage
. Does that resolve issue? – mason