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

Adding User Controls

P: n/a
I could really use some help on this.

First of all, I want to create a Web control where I render the control
completely from scratch based on information from a database.

In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of
doing this, which is declared as:

public class ConfigurableRepeater : WebControl.

So I tried selecting Add New Item and selected Web User Control (the only
control class available). It created a class declared as:

public partial class Controls_ConfigurableRepeater :
System.Web.UI.UserControl

1. Is there a way to add an override without typing it in manually? (VB and
MFC both support this.) I know I can type it in but I don't necessarily know
which overrides are available or what their call signatures are.

2. To make it like the example in the book, I think I want to derive from
WebControl. If I change it to instead be derived from WebControl, I get the
error "Error 2 Make sure that the class defined in this code file matches
the 'inherits' attribute, and that it extends the correct base class (e.g.
Page or UserControl). C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepeat er.ascx.cs 12 33
C:\...\WebSite2\". Well, I didn't change the class name so the inherits
attribute still seems correct. I know I've changed which class I'm deriving
from but I can't see how to correct that.

3. To make it like the example in the book, I think I also don't want the
partial attribute. If I remove the partial attribute, I get the error "Error
2 Missing partial modifier on declaration of type
'Controls_ConfigurableRepeater'; another partial declaration of this type
exists C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepeat er.ascx.cs 12 14
C:\...\WebSite2\." But I can see no way to find this other partial reference
in order to change that.

I guess I'm also confused about the different types of controls.

Any input would be greatly appreciated.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Dec 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
A User control is not a Web control. A user control has an ascx file that
forms the presentation end. A WebControl does not. It relies on you to
create it in code.

The control type you want is not the "Web User Control" it is the "Web
Custom Control". Now, I'm not sure if the book missed a step or not, but
you're not going to find the right control type within the normal ASP.Net
Web Site. Because the ASP.Net Web Site project is compiled as needed, it's
not compiled into a control dll like the Web Application Project (which was
the model in VS 2003 and an add-in project type in VS 2005). You may want to
try the web application project instead (downloadable from www.asp.net).
The type of project the book should tell you to create is a Windows Control
Library. There you can create Web Custom Controls and then reference the dll
within your web site.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006


"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uj****************@TK2MSFTNGP02.phx.gbl...
>I could really use some help on this.

First of all, I want to create a Web control where I render the control
completely from scratch based on information from a database.

In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of
doing this, which is declared as:

public class ConfigurableRepeater : WebControl.

So I tried selecting Add New Item and selected Web User Control (the only
control class available). It created a class declared as:

public partial class Controls_ConfigurableRepeater :
System.Web.UI.UserControl

1. Is there a way to add an override without typing it in manually? (VB
and MFC both support this.) I know I can type it in but I don't
necessarily know which overrides are available or what their call
signatures are.

2. To make it like the example in the book, I think I want to derive from
WebControl. If I change it to instead be derived from WebControl, I get
the error "Error 2 Make sure that the class defined in this code file
matches the 'inherits' attribute, and that it extends the correct base
class (e.g. Page or UserControl). C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepeat er.ascx.cs 12 33
C:\...\WebSite2\". Well, I didn't change the class name so the inherits
attribute still seems correct. I know I've changed which class I'm
deriving from but I can't see how to correct that.

3. To make it like the example in the book, I think I also don't want the
partial attribute. If I remove the partial attribute, I get the error
"Error 2 Missing partial modifier on declaration of type
'Controls_ConfigurableRepeater'; another partial declaration of this type
exists C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepeat er.ascx.cs 12 14
C:\...\WebSite2\." But I can see no way to find this other partial
reference in order to change that.

I guess I'm also confused about the different types of controls.

Any input would be greatly appreciated.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Dec 4 '06 #2

P: n/a
Mark,
>A User control is not a Web control. A user control has an ascx file that
forms the presentation end. A WebControl does not. It relies on you to
create it in code.
When I select WebSite|Add New Item, the only control available is Web User
Control. In addition, when I select this option, it does create ascx file.
The control type you want is not the "Web User Control" it is the "Web
Custom Control". Now, I'm not sure if the book missed a step or not, but
you're not going to find the right control type within the normal ASP.Net
Web Site. Because the ASP.Net Web Site project is compiled as needed, it's
not compiled into a control dll like the Web Application Project (which
was the model in VS 2003 and an add-in project type in VS 2005). You may
want to try the web application project instead (downloadable from
www.asp.net). The type of project the book should tell you to create is a
Windows Control Library. There you can create Web Custom Controls and then
reference the dll within your web site.
The book only showed what to type in. It seems entirely oblivious in many
cases that there is a very function IDE involved.

If I understood you, I need a Web User Control but cannot add that type of
control to my Web site project. Instead, the only way to create a Web
control that will render itself completely from scratch, I need to create a
control DLL. That sure doesn't sound right. Is that what you are saying?

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uj****************@TK2MSFTNGP02.phx.gbl...
>>I could really use some help on this.

First of all, I want to create a Web control where I render the control
completely from scratch based on information from a database.

In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of
doing this, which is declared as:

public class ConfigurableRepeater : WebControl.

So I tried selecting Add New Item and selected Web User Control (the only
control class available). It created a class declared as:

public partial class Controls_ConfigurableRepeater :
System.Web.UI.UserControl

1. Is there a way to add an override without typing it in manually? (VB
and MFC both support this.) I know I can type it in but I don't
necessarily know which overrides are available or what their call
signatures are.

2. To make it like the example in the book, I think I want to derive from
WebControl. If I change it to instead be derived from WebControl, I get
the error "Error 2 Make sure that the class defined in this code file
matches the 'inherits' attribute, and that it extends the correct base
class (e.g. Page or UserControl). C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepea ter.ascx.cs 12 33
C:\...\WebSite2\". Well, I didn't change the class name so the inherits
attribute still seems correct. I know I've changed which class I'm
deriving from but I can't see how to correct that.

3. To make it like the example in the book, I think I also don't want the
partial attribute. If I remove the partial attribute, I get the error
"Error 2 Missing partial modifier on declaration of type
'Controls_ConfigurableRepeater'; another partial declaration of this type
exists C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepea ter.ascx.cs 12 14
C:\...\WebSite2\." But I can see no way to find this other partial
reference in order to change that.

I guess I'm also confused about the different types of controls.

Any input would be greatly appreciated.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Dec 4 '06 #3

P: n/a
In addition to my last comments, I see that the control create does in fact
have an overridable Render() method.

Of course, I still haven't found how to see what overrides are available in
a class from the IDE. And short of typing in the control manually, I don't
have any way to test the control by adding it to a Web form.

I can't believe the IDE does not support either of these. Still looking...

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:Oj**************@TK2MSFTNGP02.phx.gbl...
>A User control is not a Web control. A user control has an ascx file that
forms the presentation end. A WebControl does not. It relies on you to
create it in code.

The control type you want is not the "Web User Control" it is the "Web
Custom Control". Now, I'm not sure if the book missed a step or not, but
you're not going to find the right control type within the normal ASP.Net
Web Site. Because the ASP.Net Web Site project is compiled as needed, it's
not compiled into a control dll like the Web Application Project (which
was the model in VS 2003 and an add-in project type in VS 2005). You may
want to try the web application project instead (downloadable from
www.asp.net). The type of project the book should tell you to create is a
Windows Control Library. There you can create Web Custom Controls and then
reference the dll within your web site.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006


"Jonathan Wood" <jw***@softcircuits.comwrote in message
news:uj****************@TK2MSFTNGP02.phx.gbl...
>>I could really use some help on this.

First of all, I want to create a Web control where I render the control
completely from scratch based on information from a database.

In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of
doing this, which is declared as:

public class ConfigurableRepeater : WebControl.

So I tried selecting Add New Item and selected Web User Control (the only
control class available). It created a class declared as:

public partial class Controls_ConfigurableRepeater :
System.Web.UI.UserControl

1. Is there a way to add an override without typing it in manually? (VB
and MFC both support this.) I know I can type it in but I don't
necessarily know which overrides are available or what their call
signatures are.

2. To make it like the example in the book, I think I want to derive from
WebControl. If I change it to instead be derived from WebControl, I get
the error "Error 2 Make sure that the class defined in this code file
matches the 'inherits' attribute, and that it extends the correct base
class (e.g. Page or UserControl). C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepea ter.ascx.cs 12 33
C:\...\WebSite2\". Well, I didn't change the class name so the inherits
attribute still seems correct. I know I've changed which class I'm
deriving from but I can't see how to correct that.

3. To make it like the example in the book, I think I also don't want the
partial attribute. If I remove the partial attribute, I get the error
"Error 2 Missing partial modifier on declaration of type
'Controls_ConfigurableRepeater'; another partial declaration of this type
exists C:\My Documents\Visual Studio
2005\WebSites\WebSite2\Controls\ConfigurableRepea ter.ascx.cs 12 14
C:\...\WebSite2\." But I can see no way to find this other partial
reference in order to change that.

I guess I'm also confused about the different types of controls.

Any input would be greatly appreciated.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com



Dec 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.