You are here:   Home
Register   |  Login
Save 20% to rip DVD to the video format you want!

Captured Technology - Blog

Minimize

Building HTML in the Page_Init Event

May 15

Written by:
5/15/2009 4:19 PM  RssIcon

Building HTML in the Page_Init Event

In relation to the CSS Rounded Corners that I wrote about recently, we needed to have the rounded corners rendered in the Page_Init event of a user control instead of being part of a markup page. Therefore I researched adding simple Html tags in code and found the HtmlControls.HtmlGenericControl method which creates generic Html controls, obviously. The CSS Rounded Corners Html code is a combination of bold tags mostly with some div tags and CSS classes to go along. Here is an example of the Html for the rounded corners in Asp.Net code behind.

        ' The Rounded Header 
        Dim objB1h As New HtmlControls.HtmlGenericControl("b")
        objB1h.Attributes.Add("class", "b1h")
        Dim objB2h As New HtmlControls.HtmlGenericControl("b")
        objB2h.Attributes.Add("class", "b2h")
        Dim objB3h As New HtmlControls.HtmlGenericControl("b")
        objB3h.Attributes.Add("class", "b3h")
        Dim objB4h As New HtmlControls.HtmlGenericControl("b")
        objB4h.Attributes.Add("class", "b4h")

        ' The Rounded Footer
        Dim objB1bh As New HtmlControls.HtmlGenericControl("b")
        objB1bh.Attributes.Add("class", "b1bh_gray")
        Dim objB2bh As New HtmlControls.HtmlGenericControl("b")
        objB2bh.Attributes.Add("class", "b2bh_gray")
        Dim objB3bh As New HtmlControls.HtmlGenericControl("b")
        objB3bh.Attributes.Add("class", "b3bh_gray")
        Dim objB4bh As New HtmlControls.HtmlGenericControl("b")
        objB4bh.Attributes.Add("class", "b4bh_gray")

        ' The Header Text
        Dim objBr As New HtmlControls.HtmlGenericControl("b")
        objBr.Attributes.Add("class", "br")
        Dim objDivHeadh As New HtmlControls.HtmlGenericControl("div")
        objDivHeadh.Attributes.Add("class", "headh")
        Dim objHeaderContainer As New MessageContainer
        HeaderTemplate.InstantiateIn(objHeaderContainer)
        objDivHeadh.Controls.Add(objHeaderContainer)

        ' The Content
        Dim objDivContenth As New HtmlControls.HtmlGenericControl("div")
        objDivContenth.Attributes.Add("class", "contenth_gray")
        Dim objBodyContainer As New MessageContainer
        BodyTemplate.InstantiateIn(objBodyContainer)
        objDivContenth.Controls.Add(objBodyContainer)

        Me.Controls.Clear()
        Me.Controls.Add(objB1h)
        Me.Controls.Add(objB2h)
        Me.Controls.Add(objB3h)
        Me.Controls.Add(objB4h)
        Me.Controls.Add(objDivHeadh)
        Me.Controls.Add(objBr)
        Me.Controls.Add(objDivContenth)
        Me.Controls.Add(objB4bh)
        Me.Controls.Add(objB3bh)
        Me.Controls.Add(objB2bh)
        Me.Controls.Add(objB1bh)

Tags:
Categories:

3 comment(s) so far...


Gravatar

Re: Building HTML in the Page_Init Event

Programming is my weakness. I find it hard to understand this.

By Sacramento dating on   5/21/2009 8:25 PM
Gravatar

Re: Building HTML in the Page_Init Event

I'm very grateful to you for providing the code. I'm searching for this code for a long time.

By Web design sunshine coast on   8/12/2009 8:00 AM
Gravatar

Re: Building HTML in the Page_Init Event

where did u get this code?

By who invented the computer on   5/25/2010 11:46 PM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 

FaceBook

Minimize

Mobile Version

Minimize
Add CapturedTech - Technology Mippin widget

Translate

Minimize

Sponsors

Minimize
Design your own Fandango Bucks gift card!

Recent Comments

Minimize
Re: Microsoft Test Bounties
I had spent a good deal of my time looking for someone to explain this subject clearly and I have really enjoyed reading your blog posts and I collected a lot of interesting things as well as I done a research on the subject and learn most peoples will agree with your blog.
Re: 10 Ways to Source Great Sales Leads
Hoovers.com, that have contact information for tens of millions of businesses. If necessary, you can work with these companies' research teams to order lists specifically tailored to your organization's sales needs.
Re: Microsoft Test Bounties
To find bugs and showing it to microsoft is quite admirable. Keep blogging more i will appreciate.
Re: Microsoft Test Bounties
Testing a software and giving out the errors to microsoft is amazing. Very good thing to do. One can do this in free time.
Re: Reindexing SQL Server Tables
Discussed about the SQL server and more interesting matter discussed in the post because in the post define about the SQL server table so that can be know that and able to understand regarding post.

u comment, i follow