2011-05-03 93 views

回答

1

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如何有其邊框顯式關閉。

相關問題