Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How to give button location in asp.net. At windows form we give as Button1.Location. In asp.net I am creating a button at run time and also adding it to a panel control. But i want to give correct Location for that button.
Posted
Comments
manognya kota 11-Jan-12 23:37pm    
Check this link for the details :

http://forums.asp.net/t/1236573.aspx/1

hello,

try this

SQL
Button button1 = new Button();
button1.Text = "button";
button1.Attributes.Add("style", "Z-INDEX: 100; LEFT: 100px; POSITION: absolute; TOP: 176px");


change the value part to render the control where you want on the web form.
 
Share this answer
 
v2
Hi,

Try this code,

C#
myComponent.Style.Add("top", topRandom.ToString() + "px");
myComponent.Style.Add("left", leftRandom.ToString() + "px");



Hope this helps.
 
Share this answer
 
Comments
ssyuvaraja 12-Jan-12 1:58am    
Location is not changing.
myComponent.Style.Add("margin-top", topRandom.ToString() + "px");
myComponent.Style.Add("margin-left", leftRandom.ToString() + "px");
 
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