default border color for .net textbox
I change the border style and border color on a .net textbox to solid red respectively. After a postback I am attempting to return the textbox to its default values, but开发者_Python百科 I cannot seem to get the color right. I have googled this, and tried to get the default values in the debugger, but the values in the debugger always look too dark of a gray when applied. Is there an easy way to return to the default look and feel of a textbox?
try this:
TextBoxTitle.BorderColor = System.Drawing.Color.Empty;
You can write two CSS classes:
.tb_with_border {
border: 1px #FF0000 solid;
}
.tb_without_border {
border: none;
}
.. and then you can change styles by assigning CssClass property of your textbox, for example:
Textbox1.CssClass = "tb_without_border";
or in markup:
<asp:TextBox id="Textbox1" runat="server" CssClass="tb_with_border" />
If you're just switching the particular element style off then this works:
Textbox1.BorderColor = Nothing
You should be using CSS to do this anyways...
Textbox1.Style.Remove("border")
txt_TextBox.BorderColor = System.Drawing.Color.Empty;
txt_TextBox.BorderStyle = BorderStyle.NotSet;
Simple. Add another textbox or dropdownlist with default values and make it hidden. To RESET to defaults, just set your textbox's border color, width and style to that of the hidden textbox like so:
txtMyTextBoxToReset.BorderColor = txtHiddenTextBox.BorderColor; txtMyTextBoxToReset.BorderWidth = txtHiddenTextBox.BorderWidth;
This works in all browsers and works for Drop down lists as well
精彩评论