Click here to Skip to main content
13,195,163 members (71,102 online)
Rate this:
 
Please Sign up or sign in to vote.
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 19-Dec-11 19:23pm
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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



For more detail click here.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

You can achive this with manu ways

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

</asp:placeholder>

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


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


in CS code
use
 
Label1.CssClass = "style1";
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

try
lblShow.Location=new point(e.X,e.Y);
or
lblShow.Location=new point(100,200);


will work :)
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171019.1 | Last Updated 3 Oct 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100