Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

Converting HTML files to User Controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ben Amada - 29 Oct 2005 13:45 GMT
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
Karl Seguin - 29 Oct 2005 14:33 GMT
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

Signature

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

> Hello,
>
[quoted text clipped - 18 lines]
> Many questions :)  Any answers are appreciated!
> Thanks/Ben
Ben Amada - 29 Oct 2005 22:36 GMT
> 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
[quoted text clipped - 9 lines]
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.