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

using .ascx file to create server control

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.