Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my application i create one dynamic label called lblShow. Now i want to set the position of that label in .cs file.How should i do this?
Posted
Updated 19-Dec-11 19:25pm
v2
Comments
Prince Antony G 20-Dec-11 1:30am    
Use Stylesheet and apply that style into that label while creating that label. Try this.

You can use Control.Style Property to set style of a control.
E.g.
C#
Label lbl = new Label();
lbl.Style[HtmlTextWriterStyle.Position] = "Absolute";
lbl.Style[HtmlTextWriterStyle.Top] = "10px";



For more detail click here.
 
Share this answer
 
v2
You can achive this with manu ways

1->
add a placeholder and put your label at runtime
C#
<asp:placeholder id="PlaceHolder1" runat="server" xmlns:asp="#unknown">


</asp:placeholder>

in CS code
C#
PlaceHolder1.Controls.Add(lbl);


2-> set CSS at runtime
CSS
style1
{
position:absolute;
left:100px;
top:150px;
}


in CS code
use
C#
Label1.CssClass = "style1";
 
Share this answer
 
try
lblShow.Location=new point(e.X,e.Y);
or
lblShow.Location=new point(100,200);


will work :)
 
Share this answer
 
v2

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