Link to home
Start Free TrialLog in
Avatar of pradeepsudharsan
pradeepsudharsan

asked on

Create DIV from Server Side

I am in need to create a DIV from server side.
If i create a new HTML generic control only a SPAN is created.
    (Dim A As New HtmlGenericControl)
So plz tell me what is the property to convert a SPAN to DIV?



Avatar of GavinMannion
GavinMannion

Instead of creating a Div Control just create the HTML dynamically.

Dim myDiv as String
myDiv = "<div id='blah'>afjkhafja</div>"

Then bind that to a placeholder or label or Response.Write it
Avatar of pradeepsudharsan

ASKER

I tried the code
But i am in need to create a DIV .so that we could bind an user control in that DIV.

Dim cell As New HtmlTableCell
                Dim strdiv As String
                cell = Table1.Rows(0).Cells(0)
                strdiv = "<div id=" & "'div1'" & " style=" & "'Z-INDEX: 105; WIDTH: 100%; POSITION: absolute; HEIGHT: 100%'" & " runat=" & "'server'" & ">" & "</div>"
                cell.InnerHtml = strdiv
                Dim uc As UserControl
                Dim dv As New HtmlGenericControl
                uc = Page.LoadControl("UC.ascx")
                uc.Visible = True
                dv = CType(Table1.Rows(0).Cells(0).Controls.Item(0), HtmlGenericControl)
                dv.Controls.Add(uc)

sorry try this code.

Table1 is created in the design time itself.

Dim cell As New HtmlTableCell
                Dim strdiv As String
                cell = Table1.Rows(0).Cells(0)
                strdiv = "<div id=" & "'div1'" & " style=" & "'Z-INDEX: 105; WIDTH: 100%; POSITION: absolute; HEIGHT: 100%'" & " runat=" & "'server'" & ">" & "</div>"
                cell.InnerHtml = strdiv
                Dim uc As UserControl

                uc = Page.LoadControl("UC.ascx")
                uc.Visible = True
                Page.FindControl("div1").Controls.Add(uc)
ASKER CERTIFIED SOLUTION
Avatar of GavinMannion
GavinMannion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial