473,398 Members | 2,404 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,398 software developers and data experts.

using .ascx file to create server control

I like the idea of being able to place server controls in an assembly
and use them in all of my web applications. On the other hand I like
the ease of using an .ascx file when I write user controls.

so far in my practice drills to learn server controls I have done a lot
of rendering calls to write HTML to the HtmlTextWriter object:

protected override void Render( HtmlTextWriter InWriter )
{
InWriter.AddStyleAttribute( "font-family", "Verdana,Arial" ) ;
InWriter.RenderBeginTag( "table" ) ;
InWriter.RenderEndTag( ) ;
}

which is a lot of work. When I write a user control I can use the
..ascx file to build the control from Web Controls and other user
controls.

Should I keep on reading up on server controls? Will I learn how to
write a server control in a similar fashion to writing a user control?

thanks,

-Steve

Nov 19 '05 #1
2 4663
Steve:
You've pretty much summed up the limitation and advantages of both methods.
My suggestion to those wishing to learn how to utilize custom server
controls has always been to start slowly and build up on your knowledge.
For example, I often say that it's important to start with simple custom
server controls which inherit existing server controls (say a label you
always want a colon appended to) and move forward.

Yes, you should continue learning about them as they provide tremendous
flexibility. There are plenty of online tutorials and examples as well to
help you. I've also used
http://www.amazon.com/exec/obidos/tg...39822?v=glance
though I'm not sure I recommend it. In my opinion the book is extremely
hard to follow and often makes custom server controls an even more
complicated thing.

Finally, an alternative to using Render is to use the CreateControl method
which would let you add your table programatically. Table table = new
HtmlTable(); .... however there are both downsides and upsides to this
alternative...

Cheers,
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I like the idea of being able to place server controls in an assembly
and use them in all of my web applications. On the other hand I like
the ease of using an .ascx file when I write user controls.

so far in my practice drills to learn server controls I have done a lot
of rendering calls to write HTML to the HtmlTextWriter object:

protected override void Render( HtmlTextWriter InWriter )
{
InWriter.AddStyleAttribute( "font-family", "Verdana,Arial" ) ;
InWriter.RenderBeginTag( "table" ) ;
InWriter.RenderEndTag( ) ;
}

which is a lot of work. When I write a user control I can use the
.ascx file to build the control from Web Controls and other user
controls.

Should I keep on reading up on server controls? Will I learn how to
write a server control in a similar fashion to writing a user control?

thanks,

-Steve

Nov 19 '05 #2
Steve:
You've pretty much summed up the limitation and advantages of both methods.
My suggestion to those wishing to learn how to utilize custom server
controls has always been to start slowly and build up on your knowledge.
For example, I often say that it's important to start with simple custom
server controls which inherit existing server controls (say a label you
always want a colon appended to) and move forward.

Yes, you should continue learning about them as they provide tremendous
flexibility. There are plenty of online tutorials and examples as well to
help you. I've also used
http://www.amazon.com/exec/obidos/tg...39822?v=glance
though I'm not sure I recommend it. In my opinion the book is extremely
hard to follow and often makes custom server controls an even more
complicated thing.

Finally, an alternative to using Render is to use the CreateControl method
which would let you add your table programatically. Table table = new
HtmlTable(); .... however there are both downsides and upsides to this
alternative...

Cheers,
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Steve Richter" <St************@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I like the idea of being able to place server controls in an assembly
and use them in all of my web applications. On the other hand I like
the ease of using an .ascx file when I write user controls.

so far in my practice drills to learn server controls I have done a lot
of rendering calls to write HTML to the HtmlTextWriter object:

protected override void Render( HtmlTextWriter InWriter )
{
InWriter.AddStyleAttribute( "font-family", "Verdana,Arial" ) ;
InWriter.RenderBeginTag( "table" ) ;
InWriter.RenderEndTag( ) ;
}

which is a lot of work. When I write a user control I can use the
.ascx file to build the control from Web Controls and other user
controls.

Should I keep on reading up on server controls? Will I learn how to
write a server control in a similar fashion to writing a user control?

thanks,

-Steve

Nov 19 '05 #3

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

Similar topics

3
by: Nathan Sokalski | last post by:
I have a User Control that I created (.ascx & .ascx.vb file pair) that I am trying to put in a separate assembly. I know that the User Control works when it is in the same project and is compiled...
5
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access...
2
by: Martin | last post by:
Hi, I want to create a number of ascx controls with edit and view modes. Previously I have put two panels in the ascx - one for view (with label subcontrols), and one for edit (with text box...
2
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a...
0
by: Steve Richter | last post by:
I like the idea of being able to place server controls in an assembly and use them in all of my web applications. On the other hand I like the ease of using an .ascx file when I write user...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
0
by: damiensawyer | last post by:
Hello all, I'm very new to all of this. I have a theme and a skin (the standard ones). I have a standard master page which is holding a custom ascx which has a treeview in it. Can someone...
3
by: Steven Nagy | last post by:
Hi all, ASP.NET : Framework 2.0 - C# A recent addition to my code generater will create GridView's and ObjectDataSource's in a control (ASCX). So the code gen creates an ascx, ascx.cs,...
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
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
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
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
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...

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.