Versucht, gebuchte Daten aus HTML-Formular in C# -Seite abrufen.Parser Fehler beim Abrufen von Formular gebucht Daten in C#
Allerdings erhalte ich diesen Fehler:
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)
{
}
}
}
Beginnen Sie mit dem Schreiben von 'C#' und 'VB' Code auf der gleichen Seite. Entfernen Sie das "Ende If". – VDWWD
@VDWWD - versucht dies, aber es stoppt immer noch nicht den Fehler Mesasge –
Sie haben uns den Code hinter der Seite nicht gezeigt. – mason