469,129 Members | 1,725 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,129 developers. It's quick & easy.

Converting HTML files to User Controls

Hello,

A partner is going to be creating some HTML files that I plan on converting
to user controls (UC) and dynamically load at runtime. I'm guessing Visual
Studio doesn't come with some utililty to convert HTML files to UCs? IOW,
I'll have to manually convert each HTML file to a UC? I've never used user
controls before, so I'm wondering what I need to add and remove to each UC
(or HTML file) to make this work. For instance, I suppose I will need to
add an ASP.NET page directive to each UC and remove the <HTML>, <HEAD> and
<BODY> tags from each UC? What else do I need to add/remove? Is the
content of each ASCX just consist of the HTML that will be inserted into a
host ASPX page?

Also, I plan on adding some ASP.NET server controls (Labels, Image controls,
etc.) to the UC. Do I need to add a <Form runat="server"> tag to the ASCX
file if I'm going to be doing this? Lastly, since I'll be loading one of
these UCs dynamically, what do I put in the host ASPX file where the UC will
be loaded ... a placeholder? Or is there a less generic control I can add
to the host ASPX file - something like <asp:Control>?

Many questions :) Any answers are appreciated!
Thanks/Ben
Nov 19 '05 #1
2 2094
Best thing to do would be to create a ASP.Net page, then create a new user
control and drop it on the page. It should give you some insight on what
you have to do.

There's no hard rule for what an uc contains, but you are right, typically
the enclosing page contains the <html><head>....</head><body><form
runat="server">...</form></body></html> and often times more. So you'll
likely not want that in your UC. Also the uc makes use of a @Control
directive, not @Page directive. As I said, you normally put the form
runat="Server" in the page, and put the user control within the form - that
way you can have multiple uc. Placeholders are good for storing controls.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"Ben Amada" <be*@REpoMOweVErpick.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
Hello,

A partner is going to be creating some HTML files that I plan on
converting to user controls (UC) and dynamically load at runtime. I'm
guessing Visual Studio doesn't come with some utililty to convert HTML
files to UCs? IOW, I'll have to manually convert each HTML file to a UC?
I've never used user controls before, so I'm wondering what I need to add
and remove to each UC (or HTML file) to make this work. For instance, I
suppose I will need to add an ASP.NET page directive to each UC and remove
the <HTML>, <HEAD> and <BODY> tags from each UC? What else do I need to
add/remove? Is the content of each ASCX just consist of the HTML that
will be inserted into a host ASPX page?

Also, I plan on adding some ASP.NET server controls (Labels, Image
controls, etc.) to the UC. Do I need to add a <Form runat="server"> tag
to the ASCX file if I'm going to be doing this? Lastly, since I'll be
loading one of these UCs dynamically, what do I put in the host ASPX file
where the UC will be loaded ... a placeholder? Or is there a less generic
control I can add to the host ASPX file - something like <asp:Control>?

Many questions :) Any answers are appreciated!
Thanks/Ben

Nov 19 '05 #2
Karl Seguin wrote:
Best thing to do would be to create a ASP.Net page, then create a new user
control and drop it on the page. It should give you some insight on what
you have to do.

There's no hard rule for what an uc contains, but you are right, typically
the enclosing page contains the <html><head>....</head><body><form
runat="server">...</form></body></html> and often times more. So you'll
likely not want that in your UC. Also the uc makes use of a @Control
directive, not @Page directive. As I said, you normally put the form
runat="Server" in the page, and put the user control within the form -
that way you can have multiple uc. Placeholders are good for storing
controls.
Karl


Hi Karl,

Thanks for addressing my questions. As you suggest, I'll go ahead and
create a new web form, add a user control to it and see what code VS
generates.

Regards,
Ben
Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by E. Tom Jorgenson | last post: by
9 posts views Thread by Tim | last post: by
5 posts views Thread by nick | last post: by
19 posts views Thread by ThatsIT.net.au | last post: by
15 posts views Thread by lxyone | last post: by
1 post views Thread by =?Utf-8?B?SG93YXJkIFBpbnNsZXk=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.