Difference between BorderStyle = NotSet and BorderStyle = None
There is a common property for every web controls, BorderStyle. It can be set to man开发者_开发知识库y values and two of them are NotSeet and None. What is the basic difference in between them?
The BorderStyle property is actually rendered out as an entry in the style
attribute in the mark-up of the control.
None
means no border, and the control will render a specific value to say that. NotSet
leaves it up to the control to decide what it should be - which should end up with the control not rendering anything at all, which means it will be up to to any css present on the page to set the border style.
This bit of code:
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);
}
renders out as this 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>
Note how Button2 has its BorderStyle explicitly turned off.
精彩评论