0

I have a very simple (currently) 1 page aspx website. It fails to compile with a message that I have not seen before. All other examples all seem to refer to master pages, which I do not have.

"Parser Error Message: 'Options.WebForm1' is not allowed here because it does not extend class 'System.Web.UI.Page'. Source Error: Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Options.WebForm1" %> Line 2:
Line 3:

Here is the top of Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"     
Inherits="Options.WebForm1" %>

<!DOCTYPE html>

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

And for Default.aspx.cs

namespace Options
{
    public partial class _Default : Page
    {

1 Answers1

2

What is Options.WebForm1 in <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Options.WebForm1" %>

It should look like this if you are using a namespace

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Options._Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:GridView runat="server" ID="grdTest"></asp:GridView>
        </div>
        <asp:TextBox runat="server" Id ="callfmptxt"/>  
    </form>
</body>
</html>

Code Behind-

using System;
using System.Web.UI;
namespace Options
{
    public partial class _Default : Page
    {
        private double callfmp = 0;
        public double BlackScholes(string CallPutFlag, double S, double X, double T, double r, double v) { return 0.0;}
        protected void allfmptxt_TextChanged(object sender, EventArgs e) { }
    }
}
Varun Mehta
  • 134
  • 10
  • Varun, I wish I understood all this as well as you do. Perfect solution and thank you! – peter gregory May 04 '17 at 12:29
  • Your wish is gonna come true, don't worry. – Varun Mehta May 04 '17 at 14:27
  • Varun, thanks for the wish, but believe it or not, it worked for an hour, then failed again with the message "Could not load type 'Options._Default". I have no idea why! Here is how the code looks <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Options._Default" %> Then in the .cs namespace Options { public partial class _Default : Page { – peter gregory May 04 '17 at 18:45
  • Can you please share your code behind and the error you are getting now. – Varun Mehta May 04 '17 at 18:49
  • Thanks Varun for your quick reply. The error message is as I wrote it. Here is more of the code that follows, but I am out of space. using System; using System.Web.UI; namespace Options { public partial class _Default : Page { private double callfmp = 0; .. public double BlackScholes(string CallPutFlag, double S, double X, double T, double r, double v) { ... } protected void callfmptxt_TextChanged(object sender, EventArgs e) { } – peter gregory May 04 '17 at 19:00