如何在运行时在asp.net中提供按钮位置 [英] How to give Button Location at run time in asp.net
本文介绍了如何在运行时在asp.net中提供按钮位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在asp.net中提供按钮位置.在Windows窗体中,我们给出为Button1.Location.在asp.net中,我在运行时创建一个按钮,还将其添加到面板控件中.但是我想为该按钮提供正确的位置.
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.
推荐答案
hello,
试试这个
hello,
try this
Button button1 = new Button();
button1.Text = "button";
button1.Attributes.Add("style", "Z-INDEX: 100; LEFT: 100px; POSITION: absolute; TOP: 176px");
更改值部分以将控件呈现在Web窗体上所需的位置.
change the value part to render the control where you want on the web form.
您好,
试试这个代码,
Hi,
Try this code,
myComponent.Style.Add("top", topRandom.ToString() + "px");
myComponent.Style.Add("left", leftRandom.ToString() + "px");
希望对您有所帮助.
Hope this helps.
myComponent.Style.Add("margin-top", topRandom.ToString() + "px");
myComponent.Style.Add("margin-left", leftRandom.ToString() + "px");
这篇关于如何在运行时在asp.net中提供按钮位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文