1
每個Web控件BorderStyle都有一個共同屬性。它可以設置爲很多值,其中兩個是NotSeet和None。它們之間的基本區別是什麼?BorderStyle = NotSet和BorderStyle = None之間的區別
每個Web控件BorderStyle都有一個共同屬性。它可以設置爲很多值,其中兩個是NotSeet和None。它們之間的基本區別是什麼?BorderStyle = NotSet和BorderStyle = None之間的區別
BorderStyle屬性實際上呈現爲控件標記中的style
屬性中的條目。
None
表示無邊框,並且控件將呈現特定的值來表示該邊界。 NotSet
將它留給控件來決定它應該是什麼 - 它應該最終與控件不會呈現任何內容,這意味着它將取決於頁面上的任何CSS來設置邊框樣式。
這段代碼:
void WebForm1_PreRender(object sender, EventArgs e)
{
b = new Button();
b.ID = "button1";
b.Width = 100;
b.Height = 50;
b.BorderStyle = BorderStyle.NotSet;
c = new Button();
c.ID = "button2";
c.Width = 100;
c.Height = 50;
c.BorderStyle = BorderStyle.None;
div1.Controls.Add(b);
div1.Controls.Add(c);
}
呈現出來,因爲這HTML:
<div id="div1">
<input type="submit" name="button1" value="" id="button1" style="height:50px;width:100px;" />
<input type="submit" name="button2" value="" id="button2" style="border-style:None;height:50px;width:100px;" />
</div>
注意將Button2如何有其邊框顯式關閉。