Define a Label Asp.net Coordinates through C#

大兔子大兔子 提交于 2019-12-13 05:05:15

问题


I need to create dinamically a System.Web.UI.WebControls.Label and define its cordinates in the Asp.net Page.

I know it absolute position (x,y). But i dont know any way to define it. Here is how i create the label:

        System.Web.UI.WebControls.Label box3 = new System.Web.UI.WebControls.Label();
        box3.Text = entradas.ElementAt(0).text;
        box3.ID = "box3";
        //need to define x and y here

The question is how to define its position. Thanks in advance


回答1:


The Label control has an Attributes property which you can use to define the labels position on the front end.

For example: -

label.Attributes.Add("style", "top:10; right:10; position:absolute;");

Alternatively, you could just apply some CSS to the rendered HTML...



来源:https://stackoverflow.com/questions/17524034/define-a-label-asp-net-coordinates-through-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!