473,383 Members | 1,815 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,383 software developers and data experts.

How to declare a label? Thanks.

Hello,

I have a label as follows:
<label id="lName" for="name">Name:<input type="text"
id="name"></input></label>

I need to declare the label in my page.aspx.vb so I can access it on
page load. How is it?

Thanks,
Miguel

Nov 19 '05 #1
4 4206
just set it runat="server"

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uW****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a label as follows:
<label id="lName" for="name">Name:<input type="text"
id="name"></input></label>

I need to declare the label in my page.aspx.vb so I can access it on page
load. How is it?

Thanks,
Miguel

Nov 19 '05 #2
Yes, I know I forgot the runat="server" but it's still not working.

What I have in my aspx.vb file is:
Protected WithEvents lname As System.Web.UI.WebControls.Label

And then on page load I have:
lname.Text = "Name:"

My HTML is:
<label id="lname" runat="server" for="fname"><input type="text"
size="55" id="fname" name="fname"></input></label>

Well I get this error:
The base class includes the field 'lname', but its type
(System.Web.UI.WebControls.Label) is not compatible with the type of
control (System.Web.UI.HtmlControls.HtmlGenericControl)

I tryied just in case something like:
Protected WithEvents lname As
System.Web.UI.HtmlControls.HtmlGenericControl

Anyway it's not working.

Can somebody please tell me what is wrong here?

Thanks,
Miguel

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:ye***@msakademik.net:
just set it runat="server"

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uW****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a label as follows:
<label id="lName" for="name">Name:<input type="text"
id="name"></input></label>

I need to declare the label in my page.aspx.vb so I can access it on page
load. How is it?

Thanks,
Miguel


Nov 19 '05 #3
Ye
Shapper,

The <label> is an HtmlControl.HtmlGenericControl control whereas the
<asp:Label> is a WebControl.Label control. Seems to me you meant to use the
latter. The <label> tag in html is usually used alongside checkboxes so that
a user can click on the label to select a checkbox.

Simply replace the <label> with <asp:Label> and declare it

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

I suspect you would want reference the textbox as well. If so use
<asp:TextBox> instead of <input type="text">. And declare it

Protected WithEvents fname As System.Web.UI.WebControls.TextBox
Hope this helps.
Cheng Yuan Yap Ye
http://kuantanzai.blogspot.com
"Shapper" wrote:
Yes, I know I forgot the runat="server" but it's still not working.

What I have in my aspx.vb file is:
Protected WithEvents lname As System.Web.UI.WebControls.Label

And then on page load I have:
lname.Text = "Name:"

My HTML is:
<label id="lname" runat="server" for="fname"><input type="text"
size="55" id="fname" name="fname"></input></label>

Well I get this error:
The base class includes the field 'lname', but its type
(System.Web.UI.WebControls.Label) is not compatible with the type of
control (System.Web.UI.HtmlControls.HtmlGenericControl)

I tryied just in case something like:
Protected WithEvents lname As
System.Web.UI.HtmlControls.HtmlGenericControl

Anyway it's not working.

Can somebody please tell me what is wrong here?

Thanks,
Miguel

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:ye***@msakademik.net:
just set it runat="server"

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uW****************@TK2MSFTNGP10.phx.gbl...
Hello,

I have a label as follows:
<label id="lName" for="name">Name:<input type="text"
id="name"></input></label>

I need to declare the label in my page.aspx.vb so I can access it on page
load. How is it?

Thanks,
Miguel


Nov 19 '05 #4
it must be <asp:label> as error indicates <label> is a HtmlGenericControl
and <asp:label> is a Label

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yes, I know I forgot the runat="server" but it's still not working.

What I have in my aspx.vb file is:
Protected WithEvents lname As System.Web.UI.WebControls.Label

And then on page load I have:
lname.Text = "Name:"

My HTML is:
<label id="lname" runat="server" for="fname"><input type="text" size="55"
id="fname" name="fname"></input></label>

Well I get this error:
The base class includes the field 'lname', but its type
(System.Web.UI.WebControls.Label) is not compatible with the type of
control (System.Web.UI.HtmlControls.HtmlGenericControl)

I tryied just in case something like:
Protected WithEvents lname As
System.Web.UI.HtmlControls.HtmlGenericControl

Anyway it's not working.

Can somebody please tell me what is wrong here?

Thanks,
Miguel

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:ye***@msakademik.net:
just set it runat="server"

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:uW****************@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I have a label as follows:
> <label id="lName" for="name">Name:<input type="text"
> id="name"></input></label>
>
> I need to declare the label in my page.aspx.vb so I can access it on
> page
> load. How is it?
>
> Thanks,
> Miguel
>

Nov 19 '05 #5

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

Similar topics

4
by: Bert | last post by:
I have a check box on page 1 of an html page with no submit button. There is a list of links that call a php display page from page 1. I want to check the status of the check box from the display...
2
by: Xerxes | last post by:
Hi, can you tell me how I can make a <label> hidden? I have hidden the field after the label: var M_Hide = isNS4?'hide':'hidden'; var M_Show = isNS4?'show':'visible'; ..... <label...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
7
by: Mike Casey | last post by:
Hello all, I have ASP.NET label controls tied to a datasource (so text will vary in length depending on the record). In IE everything looks great--text is wrapped if needed. In Netscape and...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
8
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock...
3
by: Dominique | last post by:
Hello, I tried: <aw:HyperLink runat="server" id="hlQueuedCount" labelposition="top" labelwidth="30" command="runQuery" /> as if I use the parameter width it just affect the result of the query...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
9
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-))...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.