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

User Controls and Custom Controls

Dag
Hi all,

I have a project where we use lots of user controls. We would like to move
them to private assemblied custom controls but from what I see this can't be
done because the .ascx file must be in the main project as a file...in other
words, it doesn't look like you can add a reference to a custom created
control and leverage an .asxc within it.

Is this correct?

Nov 18 '05 #1
5 1612
if you want to use the user controls in more projects, moving them to a
separate assembly would make sense. but i dont think you can have .ascx
separately.
if all your projects follow a particular folder structure, you can place
these ascx files in a folder and access the relative path from different
projects.

Av.
"Dag" <no****@yahoo.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi all,

I have a project where we use lots of user controls. We would like to
move
them to private assemblied custom controls but from what I see this can't
be
done because the .ascx file must be in the main project as a file...in
other
words, it doesn't look like you can add a reference to a custom created
control and leverage an .asxc within it.

Is this correct?

Nov 18 '05 #2
Hi Dag,

From your description, you used to use some ASP.NET UserControls in your
web applicatoin and currently want to rebuild them as ASP.NET Custom Server
control so as to embed them into assemblies. And you're wondering on how to
deal with the ascx file of the UserControl when moving to Custom
ServerControl, yes?

As for this problem, I think if you want to rebuild these control as Custom
SErver Control , the ascx file for UserControl is no longer used. Because
ServerControl is rather different from the UserControl which will need us
to manually construct it's Control hierarchy and Render out the "Html"
output via code. The UserControl's ascx file is actually a source template
which will be parsed at runtime to help generate the UserControl's actual
class , just like the Asp.net page's dynamic compiled. They're different
from each other. Here are some reference on both of them in MSDN:

#Composite Control vs. User Control
http://msdn.microsoft.com/library/en...ositecontrolvs
usercontrol.asp?frame=true

#Recommendations for Web User Controls vs. Web Custom Controls
http://msdn.microsoft.com/library/en...rcontrolsvscus
tomwebcontrols.asp?frame=true

#Developing ASP.NET Server Controls
http://msdn.microsoft.com/library/en...lopingwebforms
controls.asp?frame=true

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Convert them to Server Controls, which don't use a Template file.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Dag" <no****@yahoo.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi all,

I have a project where we use lots of user controls. We would like to move them to private assemblied custom controls but from what I see this can't be done because the .ascx file must be in the main project as a file...in other words, it doesn't look like you can add a reference to a custom created
control and leverage an .asxc within it.

Is this correct?

Nov 18 '05 #4
Create a new project for a generic .DLL.
Copy all your .ascx in this project. Add reference and all you need for
build.
Create a PostBuild event for :
- Copy all .ascx in WebApplication
- Copy .dll file in WebApplication\bin
You can have some problem in design (you are not in a webproject) and for
add new item (for ASCX there isn't the wizard outside the webappl!)

In WebApplication add a reference to the project (without copy local!)
In code behind you now can have intellisense and all you need.
The code in .aspx file for add the usercontrols you must write yourself, but
it's not difficult
Enjoy.
Brun

"Dag" <no****@yahoo.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi all,

I have a project where we use lots of user controls. We would like to move them to private assemblied custom controls but from what I see this can't be done because the .ascx file must be in the main project as a file...in other words, it doesn't look like you can add a reference to a custom created
control and leverage an .asxc within it.

Is this correct?

Nov 18 '05 #5
Bad New's...they have to be Custom Controls
Good News...its not that hard

Probably the easiest thing to do would be to change the base class to Panel.
Then on the Control's OnInit Event, instantiate all of the controls which
the designer created for you ( the Protected Shared Members) and add them
into your base clas's control collection. You'll probably end up adding a
number of additional GenericControl instances to your class as well because
those are what you'll have to use to encapsulate any html in the designer
"Dag" <no****@yahoo.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
Hi all,

I have a project where we use lots of user controls. We would like to move them to private assemblied custom controls but from what I see this can't be done because the .ascx file must be in the main project as a file...in other words, it doesn't look like you can add a reference to a custom created
control and leverage an .asxc within it.

Is this correct?

Nov 18 '05 #6

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

Similar topics

0
by: Jai | last post by:
Dear All Creating Custom Controls but Not User Controls,How to create custom controls,i.e Extending the functionality of the Existing Controls.(Web Custom Controls). Previously i have...
5
by: john | last post by:
I searched http://www.sellsbrothers.com. and could not find anything about this subject. How do I make C# User Controls Visible to Visual Basic 6.0 Applications? Thanks, John
4
by: BBFrost | last post by:
We have a data entry application written within Framework 1.0 that contains 20+ custom user controls. The controls overlay each other so that only one custom control is visible at a time. What...
10
by: BBM | last post by:
Hi, I have been developing with C# User Controls and occasionally have a problem where I "lose" a control from the design surface of the User Control. The controls that I am using to build my...
5
by: Drew | last post by:
I have a user control written in C#. This user control uses some of my mixed mode C++ libraries. My user control is currently residing on a .NET Windows Form. Everything works nicely. Now I am...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
1
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
6
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
by: Ron | last post by:
I would like some more information on custom controls, what they can do and things like that, what you would use them for etc... Can anyone here share some examples of what you have used a custom...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...

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.