Error parsing attribute 'test': Type 'System.Web.UI.Page' does not have a public property named 'tes

Discussion in 'ASP .Net' started by Bob, Feb 8, 2008.

  1. Bob

    Bob Guest

    I am getting this error when trying to use a custom property in my page
    directive:

    Error parsing attribute 'test': Type 'System.Web.UI.Page' does not have a
    public property named 'test'.

    What am I doing wrong?

    Thanks

    ===========================================
    default.aspx
    ===========================================
    <%@ Page Language="C#" CodeFile="mycorp.page.cs" Inherits="MyCorp.Page"
    Test="abc" %>
    <HTML>
    </HTML>

    ===========================================
    mycorp.page.cs
    ===========================================
    namespace MyCorp
    {
    public partial class Page : System.Web.UI.Page
    {
    private String _test = String.Empty;

    public String Test {
    get { return _test; }
    set { _test = value; }
    }
    }
    }
     
    Bob, Feb 8, 2008
    #1
    1. Advertising

  2. You've put a variable into what's known as a Page directive. You don't put
    code in there. The place you've put the Test="abc" is only for passing
    information to the Page regarding how to set it up.

    You need to really look at some of the quickstart examples over at
    www.asp.net to get a feel for how to do this. Since ASP.Net is event
    driven, you need to write code that responds to those events. If you're
    wanting to set the Test variable to some value, you need to do it at the
    right point. You also wouldn't do it in the designer surface (the .aspx
    page), you would do it in your .cs page. I'm guessing you're probably coming
    from a classic ASP or PHP background as this would be one of the first
    things someone who is used to those platforms would do. Visit the
    quickstarts and get a feel as to how the event driven nature of ASP.Net
    works as it will save you a lot of frustration.


    --
    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - Expression

    "Bob" <> wrote in message
    news:%...
    >I am getting this error when trying to use a custom property in my page
    >directive:
    >
    > Error parsing attribute 'test': Type 'System.Web.UI.Page' does not have a
    > public property named 'test'.
    >
    > What am I doing wrong?
    >
    > Thanks
    >
    > ===========================================
    > default.aspx
    > ===========================================
    > <%@ Page Language="C#" CodeFile="mycorp.page.cs" Inherits="MyCorp.Page"
    > Test="abc" %>
    > <HTML>
    > </HTML>
    >
    > ===========================================
    > mycorp.page.cs
    > ===========================================
    > namespace MyCorp
    > {
    > public partial class Page : System.Web.UI.Page
    > {
    > private String _test = String.Empty;
    >
    > public String Test {
    > get { return _test; }
    > set { _test = value; }
    > }
    > }
    > }
    >
    >
    >
    >
    >
     
    Mark Fitzpatrick, Feb 8, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    1
    Views:
    1,446
    smith
    Dec 8, 2004
  2. ~~~ .NET Ed ~~~
    Replies:
    0
    Views:
    956
    ~~~ .NET Ed ~~~
    Nov 10, 2004
  3. Anabela Silva
    Replies:
    0
    Views:
    1,291
    Anabela Silva
    Nov 1, 2006
  4. ~~~ .NET Ed ~~~
    Replies:
    0
    Views:
    212
    ~~~ .NET Ed ~~~
    Nov 10, 2004
  5. ~~~ .NET Ed ~~~
    Replies:
    1
    Views:
    246
    ~~~ .NET Ed ~~~
    Nov 13, 2004
Loading...

Share This Page