ASP.NET Interview Questions and Answers (1544) - Page 68

What do we mean by Double border-style CSS property?

It means Two solid lines on the element border or it specifies a double border on the elements or controls.
Syntax:-
border-style:double;


For Example:-
<asp:Button ID="Button2" runat="server" Text="Button" style="border-style:double;"/>

<div style="border-style:double;">Hello</div>

What do we mean by Dashed border-style CSS property?

Dashed property applies a series of dashes on the element border or it specifies a dashed border on the elements or controls.
Syntax:-
border-style:dashed;


For Example:-
<asp:Button ID="Button2" runat="server" Text="Button" style="border-style:dashed;"/>

<div style="border-style:dashed;">Hello</div>

What is the default value of border-style property?

None is the default value for border-style property.If we do not provide any value to border-style property to an element or control,then by-default it takes None value.
Which value of border-style property will be used if we do not want border on controls?

We can use border-style None value,if we do not want any border.

For Example:-
<div style="border-style:none;">Dotnet funda.com</div>

What does border-style:dotted solid double dashed mean?

border-style:dotted solid double dashed means:

top border is dotted
right border is solid
bottom border is double
left border is dashed
What does border-style:dotted solid double mean?

border-style:dotted solid double means:

top border is dotted
right and left borders are solid
bottom border is double
What does border-style:dotted solid mean?

border-style:dotted solid means:-

top and bottom borders are dotted
right and left borders are solid
What does border-style:dotted mean?

border-style:dotted means all four borders i.e. top,bottom,left and right are in dotted border.
Which border-style property must be applied with border-width property?

If we are setting control's border-width property value to any value in pixel then border-style solid,dashed,double or dotted must be applied alongwith border-width property values.

For Example:-
<asp:Button ID="Button4" runat="server" Text="Button" style="border-width:1px;border-style:solid;"/>     

<div style="border-width:2px;border-style:dotted;">Hello</div>

What is an alternative way of setting borders without CSS property?

We have a BorderWidth in-built control property through which we can set control border.It's an alternative way of setting borders.

For Example:-
<asp:Button ID="Button3" runat="server" Text="Button" BorderWidth="1px" />

What is an alternative way of setting borders style without CSS property?

We have a BorderStyle in-built control property through which we can set control border style.It has the same options as border-style CSS property.

For Example:-
<asp:Button ID="Button3" runat="server" Text="Button" BorderStyle="Solid" />  

<asp:Button ID="Button5" runat="server" Text="Button" BorderStyle="Dotted" />

How to set Control Border through code-behind?

With the help of control BorderWidth property,we can set control border width.We have to use Pixel static method of Unit class and we have to pass a numeric value in it.

For Example:-
Suppose,i have a button control like below whose border i have to set
<asp:Button ID="Button4" runat="server" Text="Button"/>

In the code behind,
We will write:
Button4.BorderWidth = Unit.Pixel(1);

What datatype Unit pixel method does in the parameter?

It has always integer datatype.

Syntax:
Unit.Pixel(int n);

What will happen if we provide string or decimal value other than integer value in Unit.Pixel method? Button1.BorderWidth = Unit.Pixel(1.5M); Button1.BorderWidth = Unit.Pixel("1");

In this case,it will give us compile time error saying that:

cannot convert from 'decimal' to 'int' in case of passing decimal values

cannot convert from 'string' to 'int' in case of passing string values

So to avoid above exception,always pass numeric value in Unit.Pixel method.
How do we set border style through code-behind?

We have control's BorderStyle property and it has BorderStyle ENUM which is to be assigned to control border style.BorderStyle ENUM has the same values which border-style CSS property has.

For Example:-
Suppose,i have a button control like below whose border style i have to set
<asp:Button ID="Button4" runat="server" Text="Button"/>

<asp:Button ID="Button5" runat="server" Text="Button"/>

In the code behind,
We will write:

Button4.BorderStyle = BorderStyle.Solid;
Button5.BorderStyle = BorderStyle.Dotted;

How to add border-style through CSSStyleCollection in code-behind?

We have control's Style attribute as CSSStyleCollection sealed class.Through which we can set border-style as shown:-

Button4.Style["border-style"] = "dashed";

Button5.Style["border-style"] = "dotted";

What is an alternative way of setting control's border-style in code-behind?

We have control's ATTRIBUTES ADD static method.In this method we have to pass style as KEY and border-style CSS property and value like solod,dotted,dashed,groove and so on as VALUE in it.
For Example:-
Button4.Attributes.Add("style", "border-style:dotted");

How to set border width through Style in code behind?

The same way as we can do with border-style in code behind.

Button4.Style["border-width"] = "2px";

Button5.Style["border-width"] = "medium";
Button6.Style["border-width"] = "thin";

What is an alternative way of setting control's border-width in code-behind?

We have control's ATTRIBUTES ADD static method.In this method we have to pass style as KEY and border-width CSS property and value like thick,thin,medium or any value in pixel and so on as VALUE in it.

For Example:-
Button1.Attributes.Add("style", "border-width:thick");

Button2.Attributes.Add("style", "border-width:2px");

How to assign a CSS for border-style and border width property?

Suppose i have a css class on the page in Head tag like below:-
.button_border

{
border-width:2px;
border-style:solid;
border-color:blue;
}

And i want to apply above class in Button control,then i will write below code:-
<asp:Button ID="Button15" runat="server" Text="Border Width 6" CssClass="button_border"/>

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories