473,473 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

[ASP.NET] Inheritance and Label

hi all, i'd like to inherit from a label, how can I do ?

i've tried:

1. making a new Web User Control, then inherit from
System.Web.UI.WebControls.Label but not works!
2. creating a class (.cs file) that inherits from the Label Control
but it didn't work!

any idea ?

Jul 16 '07 #1
16 2333
On Jul 16, 3:02 pm, RicercatoreSbadato <emailsolid...@yahoo.itwrote:
hi all, i'd like to inherit from a label, how can I do ?

i've tried:

1. making a new Web User Control, then inherit from
System.Web.UI.WebControls.Label but not works!
2. creating a class (.cs file) that inherits from the Label Control
but it didn't work!

any idea ?
Hi...
if you want to extent a asp.net server control you got to create a new
custom control
which inherits from label...
for this add a new custom web control project in vs... and then try...

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 16 '07 #2
i've done so (but it doesn't work!)

--
public partial class SuperLabel : System.Web.UI.WebControls.Label
{
protected void Page_Load(object sender, EventArgs e)
{
base.Text += "..inherited";
}
}
--

do you have tried it?
i think you have never tried it..

could you post me a working example ?

Jul 16 '07 #3
On Jul 16, 3:09 pm, RicercatoreSbadato <emailsolid...@yahoo.itwrote:
i've done so (but it doesn't work!)

--
public partial class SuperLabel : System.Web.UI.WebControls.Label
{
protected void Page_Load(object sender, EventArgs e)
{
base.Text += "..inherited";
}}

--

do you have tried it?
i think you have never tried it..

could you post me a working example ?
Hi...

here is a complete set of tutorials... how to develop a custom server
control...
http://msdn2.microsoft.com/en-us/library/yhzc935f.aspx
Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com
Jul 16 '07 #4
tnx for your support but don't reply only to say something.
my question is precise: I'D LIKE TO CREATE A CONTROL TAHT INHERITS
FROM A LABEL,
then: are you able to do it ? If yes, could you post me a little
example ?

Jul 16 '07 #5
On Jul 16, 3:16 pm, RicercatoreSbadato <emailsolid...@yahoo.itwrote:
tnx for your support but don't reply only to say something.
my question is precise: I'D LIKE TO CREATE A CONTROL TAHT INHERITS
FROM A LABEL,
then: are you able to do it ? If yes, could you post me a little
example ?
Hi..

Okay here is a code sample...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyCustomLabel
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:WebCustomControl1 runat=server></
{0}:WebCustomControl1>")]
public class WebCustomControl1 : Label
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? String.Empty : s);
}

set
{
ViewState["Text"] = value;
}
}

protected override void RenderContents(HtmlTextWriter output)
{
output.Write(Text + "FromMunnacs");
}
}
}

this works... i have tested it...

here what i did...
first add a web control library from vs project templete...
then changed the
public class WebCustomControl1 : WebControl
to
public class WebCustomControl1 : Label

ofcourse i changed the rendercontent....

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 16 '07 #6
Please always post the error message you get.

The Page_Load event belongs to the Page object not to the Label object so
your code is never called (basically you created a new method that is not
used by ASP.NET).
--
Patrice

"RicercatoreSbadato" <em***********@yahoo.ita écrit dans le message de
news: 11**********************@d55g2000hsg.googlegroups. com...
i've done so (but it doesn't work!)

--
public partial class SuperLabel : System.Web.UI.WebControls.Label
{
protected void Page_Load(object sender, EventArgs e)
{
base.Text += "..inherited";
}
}
--

do you have tried it?
i think you have never tried it..

could you post me a working example ?

Jul 16 '07 #7
ok, tnx but can you show me the ASCX side ? i receive an error from my
debugger..

Jul 16 '07 #8
On Jul 16, 3:40 pm, "Patrice" <http://www.chez.com/scribe/wrote:
Please always post the error message you get.

The Page_Load event belongs to the Page object not to the Label object so
your code is never called (basically you created a new method that is not
used by ASP.NET).

--
Patrice

"RicercatoreSbadato" <emailsolid...@yahoo.ita écrit dans le message denews: 1184576951.424595.101__BEGIN_MASK_n#9g02mG7!__..._ _**********************@d55g2000hsg.googlegroups.c om...
i've done so (but it doesn't work!)
--
public partial class SuperLabel : System.Web.UI.WebControls.Label
{
protected void Page_Load(object sender, EventArgs e)
{
base.Text += "..inherited";
}
}
--
do you have tried it?
i think you have never tried it..
could you post me a working example ?
Hi,

why do you have to use a page load in custom server control...
you dont have to put any page load method...
"RenderContents" method is doing your job....

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 16 '07 #9
i don't use the Page_Load() anymore. but the debugger says to me that
the ascx file inherits from a bad source.. could you show me the
source of you ascx file?
tnx.

Jul 16 '07 #10
On Jul 16, 3:57 pm, RicercatoreSbadato <emailsolid...@yahoo.itwrote:
i don't use the Page_Load() anymore. but the debugger says to me that
the ascx file inherits from a bad source.. could you show me the
source of you ascx file?
tnx.
Hi...

oh i got it... you are trying all these things in a ascx file, that
is... in a usercontrol, right?...
as i mentioned before you got to create a custom web control
Library...

steps...

1. Right Click on your solution file...
2. Select Add ->New Project ...
3. Now Select Web Control Library from Visual c# Project templates...
4. By default vs2005 will create the necessary files for you....

you use your control...
first compile...
and then add to your vs2005 toolbox..
and then drag and drop just like other asp.net controls...

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com


Jul 16 '07 #11
there is a misunderstanding.. when U create a WebUserControl the VS
Environment creates a ascx file too..

Jul 16 '07 #12
On Jul 16, 4:08 pm, RicercatoreSbadato <emailsolid...@yahoo.itwrote:
there is a misunderstanding.. when U create a WebUserControl the VS
Environment creates a ascx file too..
Hi....

""when U create a WebUserControl the VS Environment creates a ascx
file too.""

we are not creating webusercontrol... we will be creating a custom
control... custom control will not have any .ascx file only a class
file....

i am reaping the steps again...

steps...

2. Select File - Add ->New Project ...
3. Now Select Web Control Library from Visual c# ->Windows.....
Project templates...
4. By default vs2005 will create the necessary files for you....
Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 16 '07 #13
ok, now I have understood.

1.
when I have a label I can write inside it. with my Custom Control how
can i read the inner text ? for example i'd like to read "ciao ciao
ciao", how can i do it? the Text properties doesn't work..

<cc1:webcustomcontrol1 id="WebCustomControl1_1"
runat="server">
ciao ciao ciao
</cc1:webcustomcontrol1>

2.
is there a way to create a Custom Control whitout create a NEW
project? i'd like to create a custom control from my WebSiteProject..

tnx for the help.

Jul 16 '07 #14
2.
done, the this.Text contains the InnerText.

Jul 16 '07 #15
Hi Ricercatore

is there a way to create a Custom Control whitout create a NEW
project? i'd like to create a custom control from my WebSiteProject..
yes, of course
you can simply add a new Class file to your project, whitch includes the
customcontrol code
for later implementing on your ASPX Page, you have to refer to the Assembly
Name of your Website / Webapplication Project, on the Page Register
Directive.

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

Jul 16 '07 #16
OK, TNX ALL!
;-)

Jul 16 '07 #17

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

Similar topics

1
by: ramonred | last post by:
Hi, I am following along an example from the book <b>Beginning Visual Web Programming in C#</b> My environment is this: IIS 5.1 on XP Pro, I have the checkbox 'use windows integrated...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
11
by: Steve Hoyer | last post by:
I am trying to deploy my first asp.net app to our webserver (2K server, IIS 5) My start page comes up and you can get to the subsequent pages that are tied into our sql server (2K). Each page...
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
8
by: Radx | last post by:
Here in my web application, I have a data entry page with serval controls. Some of the controls have autopostback is set true. But the problem is when two or more people are entering data at the...
4
by: shamirza | last post by:
4 9 6 18.ATLAS-AJAX Note: - As an IT professional it's useful to know what the difference is between Hype and usefulness. For instance if there is a new technology coming in many programmers...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
1
by: luvkling | last post by:
hi, i am new to asp.net. i currently doin a website. i created a add form in this form the user need to add in the record n when they press the submit button it will add the record into the access...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.