Where to generate literal controls

S

Scott M.

I'm not sure where I should be placing the code that creates my literal
controls. They are rendering but AFTER the close of the HTML tag.

I've tried Load, Init, PreLoad, PreInit, PreRender and get the same result
each time:

Example code:

Controls.Add(New LiteralControl("<div>"))
Dim lblItem As New Label
lblItem.Text = ("<p>") & item.Element("title").Value
lblItem.Font.Bold = True
lblItem.Style.Item("display") = "block"
lblItem.Style.Item("width") = "350px"
Controls.Add(lblItem)
 
S

sravan_reddy001

--Try to add a panel on the aspx page where u want all these literal
controls in the page...

let the panel u inserted in ur page is "asppanel1"
then u can add those literal controls as asppanel1.controls.Add(New
LiteralControl("<h1>"+(any thing u wanna display)+"</h1>"))
and u can place these this on "pageLoad" method....
 
S

Scott M.

I wanted to produce html output within the <body><form and </form></body>,
but instead was getting all my controls in the output, following the
</html>.

The problem is solved now, though. I did add a panel control at design-time
and then added my literals to that at run-time.

Thanks.


Eliyahu Goldin said:
Can you show the html output you want to produce and what is the code
actually producing?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Scott M. said:
I'm not sure where I should be placing the code that creates my literal
controls. They are rendering but AFTER the close of the HTML tag.

I've tried Load, Init, PreLoad, PreInit, PreRender and get the same
result each time:

Example code:

Controls.Add(New LiteralControl("<div>"))
Dim lblItem As New Label
lblItem.Text = ("<p>") & item.Element("title").Value
lblItem.Font.Bold = True
lblItem.Style.Item("display") = "block"
lblItem.Style.Item("width") = "350px"
Controls.Add(lblItem)
 
E

Eliyahu Goldin

Ok. Just note that there is a server control specially made for that
purpose. It is called PlaceHolder.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Scott M. said:
I wanted to produce html output within the <body><form and </form></body>,
but instead was getting all my controls in the output, following the
</html>.

The problem is solved now, though. I did add a panel control at
design-time and then added my literals to that at run-time.

Thanks.


Eliyahu Goldin said:
Can you show the html output you want to produce and what is the code
actually producing?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Scott M. said:
I'm not sure where I should be placing the code that creates my literal
controls. They are rendering but AFTER the close of the HTML tag.

I've tried Load, Init, PreLoad, PreInit, PreRender and get the same
result each time:

Example code:

Controls.Add(New LiteralControl("<div>"))
Dim lblItem As New Label
lblItem.Text = ("<p>") & item.Element("title").Value
lblItem.Font.Bold = True
lblItem.Style.Item("display") = "block"
lblItem.Style.Item("width") = "350px"
Controls.Add(lblItem)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top