473,513 Members | 2,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding User Controls

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
3 1865
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3705
by: avivgur | last post by:
Hello, I am writing a program in Visual C# and I have encountered a problem. In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling...
4
5450
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
4858
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
2327
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
5
1512
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
3
2110
by: Bart Van Hemelen | last post by:
I'm working on a project where the user of a site will receive custom content, depending on a set of parameters. The content will all be contained in UserControls (.ascx), that will be used as...
6
11058
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
2
359
by: Chris Botha | last post by:
I am adding controls dynamically to the page as per the samples there are on the Web and it works - I can create text boxes, buttons, my own user controls, whatever, on the fly and initialize them...
2
1940
by: Chris | last post by:
I am getting a viewstate error when adding dynamically user controls. SYSTEM_EXCEPTION:Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree...
2
15044
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
0
7257
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
7535
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
7098
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
7521
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
5682
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
4745
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...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
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.