Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends

1st i will create 2 divs in code behind like this

C#
sb.Append("<div id="left" style="float:left;width:50%">");


and
C#
sb.Append("<div id="right" style="float:right;width:50%">");


now i want to place multiple controls inside the div using the ids of div

if i want to place control on right it should be placed on right side div using id 'right'

if i want to place control on left it should be placed on left side id 'Left'

Note: All in code behind

How to achive it..
Posted
Updated 16-Feb-15 22:07pm
v2
Comments
Kornfeld Eliyahu Peter 17-Feb-15 1:58am    
Controls === ASP.NET controls?
murkalkiran 17-Feb-15 2:02am    
Ya Which Created Dynamically
Sinisa Hajnal 17-Feb-15 2:26am    
Redesign. You're going about it wrong way. Instead of concatenating controls, use ASP.NET controls (create two ASP:Panel controls with RIGHT/LEFT ids and add into their controls collection whatever you need.

As long as you create your page content as using string builder you can not add dynamic controls...
What you have to do is adding controls to the parent control's Controls property...
Something like this:
C#
HtmlGenericControl oDiv = new HtmlGenericControl("div");
Label oLabel = new Label();

oDiv.Controls.Add(oLabel);

Page.Controls.Add(oDiv);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900