我需要動態更改此元素的寬度。所以我想從aspx.cs文件中添加一個width =「」屬性。我怎樣才能做到這一點?如何從aspx.cs中添加HTML屬性
<MyControl:Graph id="Graph1" runat="server" Height="510px"></MyControl:Graph>
我需要動態更改此元素的寬度。所以我想從aspx.cs文件中添加一個width =「」屬性。我怎樣才能做到這一點?如何從aspx.cs中添加HTML屬性
<MyControl:Graph id="Graph1" runat="server" Height="510px"></MyControl:Graph>
Graph1.Width = 500;
可能就足夠了。
如果您的控件繼承自WebControl,它將會有一個名爲Attributes的屬性。 您可以輸入:
Graph1.Attributes["height"] = "510"
請記住,在HTML的width
或height
屬性不包含單位信息,它只是一個簡單的整數。 如果你正在尋找一個CSS inplementation使用:
Graph1.Style["height"] = "510px"
博特確保你的問題是什麼? –