473,399 Members | 3,401 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,399 software developers and data experts.

How do I build a control without an .ascx file, only with a DLL?

Hello,

I would like to build a control that outputs some text. Due to the
simple nature of the output, if I did it with an .ascx file and a
code-behind, the .ascx would only contain a Literal control and nothing
else.

It seems that it would be much neater if I could do away with the .ascx
file and have the control totally contained within a DLL. I am sure this
isn't hard, but I can't work out how to write the code.

Any help would be appreciated. TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 19 '05 #1
7 1359
What you want is a custom web control, which is essentially a class
that inherits a asp.net web control. eg. TextBox

class MyTextBox : TextBox
{

}

Dec 19 '05 #2
It sounds like you want to create a custom control instead of a user
control.
Here are the details:
http://SteveOrr.net/faq/usercustom.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:kP**************@nospamthankyou.spam...
Hello,

I would like to build a control that outputs some text. Due to the simple
nature of the output, if I did it with an .ascx file and a code-behind,
the .ascx would only contain a Literal control and nothing else.

It seems that it would be much neater if I could do away with the .ascx
file and have the control totally contained within a DLL. I am sure this
isn't hard, but I can't work out how to write the code.

Any help would be appreciated. TIA

--
Alan Silver
(anything added below this line is nothing to do with me)

Dec 20 '05 #3
>It sounds like you want to create a custom control instead of a user
control.
Here are the details:
http://SteveOrr.net/faq/usercustom.aspx


Thanks Steve. Your article went into some details about user controls,
but then just said that custom controls are different, without showing
an example code.

However, armed with the knowledge that I was wanting a custom control, I
did a quick search and found loads of articles explaining how to do it.
It's quite easy really!!

Thanks again

--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 20 '05 #4
Actually Steve's stite has alot of sample code for custom controls.
Remember, he's considered the 'Control Freak' :)

Dec 20 '05 #5
>Actually Steve's stite has alot of sample code for custom controls.
Remember, he's considered the 'Control Freak' :)


I know, I was referring to that one article, which didn't have any code
for custom controls, nor links to sample code.

I wasn't criticising, merely passing comment. I have used his site many
times ;-)

--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 20 '05 #6
See http://blogs.msdn.com/davidebb/archi...30/487160.aspx on
one approach using 2.0. You can now re-use user controls as dlls.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 20 Dec 2005 19:42:48 +0000, Alan Silver
<al*********@nospam.thanx> wrote:
Actually Steve's stite has alot of sample code for custom controls.
Remember, he's considered the 'Control Freak' :)


I know, I was referring to that one article, which didn't have any code
for custom controls, nor links to sample code.

I wasn't criticising, merely passing comment. I have used his site many
times ;-)


Dec 20 '05 #7
>See http://blogs.msdn.com/davidebb/archi...30/487160.aspx on
one approach using 2.0. You can now re-use user controls as dlls.
Thanks, that's a useful link. As it happens, the control in question was
really simple anyway as far as the UI was concerned, so it was very easy
to do as a custom control once I knew the basics (which took about five
seconds to learn once I knew it was called a custom control!!). The
control just generated plain text, so I inherited it from Control and
overrode the Render method.

Having said that, I have some other controls that would benefit greatly
from this tip. Thanks again.
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 20 Dec 2005 19:42:48 +0000, Alan Silver
<al*********@nospam.thanx> wrote:
Actually Steve's stite has alot of sample code for custom controls.
Remember, he's considered the 'Control Freak' :)


I know, I was referring to that one article, which didn't have any code
for custom controls, nor links to sample code.

I wasn't criticising, merely passing comment. I have used his site many
times ;-)


--
Alan Silver
(anything added below this line is nothing to do with me)
Dec 20 '05 #8

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

Similar topics

6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
0
by: Jacob Avlund | last post by:
Hello all, I wish to load two user controls (cart.ascx and products.ascx) programatically. What I'm doing right now: In my aspx file, two references are added: <%@ Reference...
3
by: MattGood | last post by:
Hi! I can't show a ascx-control in a correct manner when the ascx-control uses another ascx-control, the IsPostBack and ViewState's etc. don't seems to work, problably because there can only be...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
2
by: Alan Silver | last post by:
Hello, I have a user control that has one .cs file, with several .ascx files that call it. The reason for this is that I can pick whichever of the ..ascx files I want (based on a site owner...
2
by: tshad | last post by:
User VS 2003, I would like to use User Controls to control the page look with 3 User Controls (...PageTop.ascx, ...NavigateTop.ascx and PageBottom.ascx). I would put the Content User control...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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,...

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.