By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,087 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

How to declare a label? Thanks.

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.