473,410 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

question about declaring labels and errors from VWDeveloper

When I add a label to my page like this :

<asp:Label id="Message" Text="" Runat="Server"/>

and code like this:

Sub Page_load( s As Object, e As EventArgs )
Message.Text = " whatever "
End sub

I get a error warning from Visual Web Developer that says "Name 'Message' is not declared"

how do I declare the asp:label ?
Dec 29 '05 #1
16 1325
If you did this manually, then there would be no declaration in the code
behind class and therefore your code would not see it.
use the designer to add the code. If you dont have a designer, then you
will need to declare this in code behind at class level

Protected WithEvents lblMessage As System.Web.UI.WebControls.Label

Remember, your aspx page is actually a class template which inherits from
the code behind class, if you look in the page declarations on your aspx
page at the top you will see this.

HTH
--
Best Regards

The Inimitable Mr Newbie º¿º
"Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message
news:e3**************@TK2MSFTNGP11.phx.gbl...
When I add a label to my page like this :

<asp:Label id="Message" Text="" Runat="Server"/>

and code like this:

Sub Page_load( s As Object, e As EventArgs )
Message.Text = " whatever "
End sub

I get a error warning from Visual Web Developer that says "Name 'Message'
is not declared"

how do I declare the asp:label ?

Dec 29 '05 #2
interesting. This appears to be a VWD thing, which does have a designer, but I added everything manually into the source page.

I also don't use code behind, which is a valid option in VWD. So, when I drag the label from the toolbox into the source page (or
design page) VWD does not automatically add anything else.

However, when I drag the code into the page from the tool box, then add the script code manually, the error message does not appear.

Go figure........
Dec 29 '05 #3
By VWD, you mean what ?

In any case, in order to address a class member, it must be have been
declared in the first place, this goes without saying really. I'm not really
sure how your setup is configured and what tools you are using so its a
little difficult.
--
Best Regards

The Inimitable Mr Newbie º¿º
"Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
interesting. This appears to be a VWD thing, which does have a designer,
but I added everything manually into the source page.

I also don't use code behind, which is a valid option in VWD. So, when I
drag the label from the toolbox into the source page (or design page) VWD
does not automatically add anything else.

However, when I drag the code into the page from the tool box, then add
the script code manually, the error message does not appear.

Go figure........

Dec 29 '05 #4
VWD = Microsoft's Visual Web Developer Express 2005
Dec 29 '05 #5
OK, I dont have much experience with that yet, however, you say you dont use
code behind. You do, trust me! 2005 uses partial classes, so you wont
necessarily see the designer code, its made that way to seperate you from
what the designer is doing,

Are you using beta code still or release ?

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
VWD = Microsoft's Visual Web Developer Express 2005

Dec 29 '05 #6
it's the release version.

If it's hiding code somewhere, then I have no idea what to do for these problems.
I can only refer to files/code in the website that are visible to me.

"Mr Newbie" <he**@now.com> wrote in message news:u3*************@TK2MSFTNGP15.phx.gbl...
OK, I dont have much experience with that yet, however, you say you dont use code behind. You do, trust me! 2005 uses partial
classes, so you wont necessarily see the designer code, its made that way to seperate you from what the designer is doing,

Are you using beta code still or release ?

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jon Paal" <Jon nospam Paal @ everywhere dot com> wrote in message news:u3**************@TK2MSFTNGP09.phx.gbl...
VWD = Microsoft's Visual Web Developer Express 2005


Dec 30 '05 #7
Mr Newbie wrote:
OK, I dont have much experience with that yet, however, you say you
dont use code behind. You do, trust me! 2005 uses partial classes, so
you wont necessarily see the designer code, its made that way to
seperate you from what the designer is doing,

Are you using beta code still or release ?


Newbie,

Couple of clarifications. You do not have to declare the label. ASP.NET
does that at runtime. That's the whole point behind partial classes. One
other minor point... you really wouldn't want to declare a label with the
WithEvents keyword since the label doesn't really have any events that you
would want to handle.

It is certainly possible to not use code-behind in both VWD and VS 2005.

As to the OP's point, can you post all of your code copied and pasted into a
message? What you've entered here should work fine.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #8
OK, this was not the case (AFAIK) for 2003 version, I take it that this has
changed for 2005?. And as far as my example was concerned, this is what the
designer created for me in 2003 when I dragged the label onto the design
canvass. I jsut copied and pasted it to this posting.

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jim Cheshire" <no*****@none.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
Mr Newbie wrote:
OK, I dont have much experience with that yet, however, you say you
dont use code behind. You do, trust me! 2005 uses partial classes, so
you wont necessarily see the designer code, its made that way to
seperate you from what the designer is doing,

Are you using beta code still or release ?


Newbie,

Couple of clarifications. You do not have to declare the label. ASP.NET
does that at runtime. That's the whole point behind partial classes. One
other minor point... you really wouldn't want to declare a label with the
WithEvents keyword since the label doesn't really have any events that you
would want to handle.

It is certainly possible to not use code-behind in both VWD and VS 2005.

As to the OP's point, can you post all of your code copied and pasted into
a message? What you've entered here should work fine.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #9
Mr Newbie wrote:
OK, this was not the case (AFAIK) for 2003 version, I take it that
this has changed for 2005?. And as far as my example was concerned,
this is what the designer created for me in 2003 when I dragged the
label onto the design canvass. I jsut copied and pasted it to this
posting.


Yeah, it was the case with 2003.

The 2003 designer does declare it using the WithEvents keyword because there
are events defined in the class. However, this is not something you would
typically do.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #10
Thats a good point. It doesent make sense to add the withevents clause for a
label most of the time, but its probably more trouble than its worth to
remove it. Esp if you have a shed load of labels.

I wonder how much difference it would make if you had 100 labels, would it
make bringing up the page in postback slower because the withevents was used
?

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jim Cheshire" <no*****@none.com> wrote in message
news:e5**************@TK2MSFTNGP12.phx.gbl...
Mr Newbie wrote:
OK, this was not the case (AFAIK) for 2003 version, I take it that
this has changed for 2005?. And as far as my example was concerned,
this is what the designer created for me in 2003 when I dragged the
label onto the design canvass. I jsut copied and pasted it to this
posting.


Yeah, it was the case with 2003.

The 2003 designer does declare it using the WithEvents keyword because
there are events defined in the class. However, this is not something you
would typically do.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #11
Mr Newbie wrote:
Thats a good point. It doesent make sense to add the withevents
clause for a label most of the time, but its probably more trouble
than its worth to remove it. Esp if you have a shed load of labels.

I wonder how much difference it would make if you had 100 labels,
would it make bringing up the page in postback slower because the
withevents was used ?


That's a good question. In fact, when you declare it with the WithEvents
keyword, the compiler will actually create the Label as a property. You can
use ILDasm to see this. The fact that you are now referencing a property
does carry a small performance hit, but you won't notice it all. It's one of
those things that MIGHT be measurable if done at an extremely large scale,
but will never be noticeable.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #12
I have a question for you.

I am writing and application which allows the author to create articles and
then the idea is they can submit it for publcation. The contents are stored
in an sql database. So far so good, but now I have the composite parts I
need to write the code to write it out to an HTML file in a subdirectory.

What pattern would you recommend to actually do the construction of the html
?

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jim Cheshire" <no*****@none.com> wrote in message
news:eu****************@TK2MSFTNGP15.phx.gbl...
Mr Newbie wrote:
Thats a good point. It doesent make sense to add the withevents
clause for a label most of the time, but its probably more trouble
than its worth to remove it. Esp if you have a shed load of labels.

I wonder how much difference it would make if you had 100 labels,
would it make bringing up the page in postback slower because the
withevents was used ?


That's a good question. In fact, when you declare it with the WithEvents
keyword, the compiler will actually create the Label as a property. You
can use ILDasm to see this. The fact that you are now referencing a
property does carry a small performance hit, but you won't notice it all.
It's one of those things that MIGHT be measurable if done at an extremely
large scale, but will never be noticeable.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #13
Mr Newbie wrote:
I have a question for you.

I am writing and application which allows the author to create
articles and then the idea is they can submit it for publcation. The
contents are stored in an sql database. So far so good, but now I
have the composite parts I need to write the code to write it out to
an HTML file in a subdirectory.
What pattern would you recommend to actually do the construction of
the html ?


I try to avoid recommending specifics without a LOT of details on
architecture. Right off, I would wonder why you would need to actually
serialize such a thing to disk.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #14
The answer to this is simple. The serialization is to do with search
engines. In order to get the traffic you need to get spidered.

There is probably a better way to do it, but I'm not aware how!

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jim Cheshire" <no*****@none.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
Mr Newbie wrote:
I have a question for you.

I am writing and application which allows the author to create
articles and then the idea is they can submit it for publcation. The
contents are stored in an sql database. So far so good, but now I
have the composite parts I need to write the code to write it out to
an HTML file in a subdirectory.
What pattern would you recommend to actually do the construction of
the html ?


I try to avoid recommending specifics without a LOT of details on
architecture. Right off, I would wonder why you would need to actually
serialize such a thing to disk.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #15
Mr Newbie wrote:
The answer to this is simple. The serialization is to do with search
engines. In order to get the traffic you need to get spidered.

There is probably a better way to do it, but I'm not aware how!


Okay. In that case, it would depend on a number of factors. Without a
detailed review, I would not want to recommend any particular approach.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #16
Doesent matter, ive progressed it now. Thanks anyway

--
Best Regards

The Inimitable Mr Newbie º¿º
"Jim Cheshire" <no*****@none.com> wrote in message
news:u0**************@TK2MSFTNGP09.phx.gbl...
Mr Newbie wrote:
The answer to this is simple. The serialization is to do with search
engines. In order to get the traffic you need to get spidered.

There is probably a better way to do it, but I'm not aware how!


Okay. In that case, it would depend on a number of factors. Without a
detailed review, I would not want to recommend any particular approach.

--
Jim Cheshire
================================
Blog: http://blogs.msdn.com/jamesche

Latest entry: Digging into Objects
Describes the details of digging into
memory usage with the debugger.

Dec 30 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: madeo | last post by:
hi, i'm looking for some script which would export address labels from a mysql db to pdf ... There's an exapmle, but i'm not able to convert it for using with mysql ... can anybody help? THX...
5
by: Bob Bedford | last post by:
I've a query where I retrieve 2 codes. select ida, idb from mytable. I've an other table where I've some "labels". id:1 text:shoes id:2 text:socks .....
55
by: ben | last post by:
is it true that a function without an inline keyword never get inlined? If not true when is it inlined or not? ben
27
by: Terry Olson | last post by:
I'm trying to build a table on an output page based on text input by the user. And what I am trying to do is create 4 table data boxes on a row, then start a new row on the 5th one. But I can't...
2
by: Fred | last post by:
Hi. Sorry, but I don't know where else to ask. I wrote a access shipping database and we currently use the web interface for DHL to print shipping labels. That means we have to manualy transpose...
11
by: Patrick Olurotimi Ige | last post by:
Is Visual Web Developer is it worth installing? Can i use Web Matrix with ASP.Net 2.0? Cos i know VWDeveloper is meant for ASP.Net 2.0 and not ver 1.1. Can both run side by side? ***...
18
by: Nathan | last post by:
If you're wondering why I post so many questions, it's because I want to make an entry in the Guinness Book of World Records. But because I post so many, I try to make them simple. Here is (I...
0
by: benny | last post by:
Hi, i'm trying to transform an anonymous user profile to an authenticated user profile. I found this global.asax here below and there are some things i don't understand. 1) where does the...
0
by: dbsog7777 | last post by:
I was trying to use the sample code below, but I encountered two errors: Application.DoEvents() and AutoText(entry). I am not sure how to correct the errors. I trying to use the sample code to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.