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

B

Bob

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; }
}
}
}
 
M

Mark Fitzpatrick

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top