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

What is an alternative way of setting font as bold?

There is an in-built style property called font-weight,which can be applied on textbox,label t set their's font as bold.It has bold value.

For Example:-
<asp:TextBox ID="TextBox3" runat="server" style="font-weight:bold;" Text="Vishal"></asp:TextBox>

What are the options available for font-weight style property?

There are so many options available for font-weight style property some are listed below:-
1).bold
2).bolder
3).lighter
4).normal
5).100
6).200
What is an alternate way of changing Text Color?

We have an in-built style property named COLOR,which is used for changing Text Color to our choice.We can provide either #(hash) code for color or directly write color names i.e. blue,red,green and so on..

For Example:-
<asp:TextBox ID="TextBox1" runat="server" style="color:#00ff90;"></asp:TextBox>

<asp:TextBox ID="TextBox2" runat="server" style="color:blue;"></asp:TextBox>

How to set font style as Italic or what is an alternate way?

We have font-style as an in-built style property,which is used for setting font.font-style has italic option.
For Example:-
<asp:TextBox ID="TextBox1" runat="server" style="font-style:italic;"></asp:TextBox>

Which option is the default option for font-style property?

font-style property has a NORMAL option,which is said to be the default option.By setting this option,Text will be normal i.e. no italic,no oblique.
For Example:-
<asp:TextBox ID="TextBox1" runat="server" style="font-style:normal;"></asp:TextBox>

How to align Text to the left side?

We have text-align in-built style property,which is used for aligning Text to any choice.

It has Left option,which is used for aligning Text as Left-Side.

For Example:-
<asp:TextBox ID="txt_employee" runat="server" style="text-align:left;" Text="Vishal"></asp:TextBox> 

How to Right aligned any Text?

Use text-align style property Right option for aligning Text to Right-Side.

For Example:-
<asp:TextBox ID="txt_amount" runat="server" style="text-align:right;" Text="0"></asp:TextBox> 

What are the options available for TextAlign property?

We have Left and Right options for TextAlign property for Checkbox.

For Example:-
<asp:CheckBox ID="CheckBox1" runat="server" Text="Yes" TextAlign="Left"/>

<asp:CheckBox ID="CheckBox2" runat="server" Text="No" TextAlign="Right"/>

How to assign value to checkboxes.

Use Text property to assign value to checkbox.

For Example:-
<asp:CheckBox ID="CheckBox1" runat="server"/>

On code behind:
CheckBox1.Text = "Yes";

What is the default value of textalign property of checkboxex if we do not assign value to textalign property?

By-default checkboxex textalign property has Left option assigned if we do not provide then textalign takes Left option.
How to assign Checkbox value in Client-Side?

We use value property to assing checkboxes value.

For Example:-
<asp:CheckBox ID="CheckBox1" runat="server"/>


function assign_value()
{
document.getElementById('CheckBox1').value = "Yes";
}

What is the reason,if Checkbox event is not firing?

Enable AutoPostBack property to True in checkbox definition,then only Checkbox event will be fired.
How to write CSS in asp.net page?

We can write CSS class in Asp.Net as follows:-
<head>

<title></title>
<style type="text/css">
.body
{
background-color:lightyellow;
}
.label_bold
{
font-weight:bold;
}
</style>
</head>

How to call CSS class on controls?

We have a CSSClass in-built property of a controls,through which we can call any css class as follows:

<asp:Label ID="lbl_name" runat="server" Text="Name:" CssClass="label_bold" ></asp:Label>

What is the alternate way of calling CSS on controls?

We have a Class in-built property of a controls,this is an alternate way of calling CSS on controls

<asp:Label ID="lbl_name" runat="server" Text="Name:" class="label_bold" ></asp:Label>

Where is the best place to write CSS classes on Asp.Net page?

NOTE: This is objective type question, Please click question title for correct answer.
Which tag should be included while writing CSS classes on the pages?

Style tag must be included while writing CSS classes on the Asp.Net pages.

For Example:-

<style type="text/css">

//write css class here
</style>

How to apply CSS class dynamically?

With the help of Control'Style property,we can apply css at run-time,suppose i want to set Body background color,then we will write as:-
<body id="bdy" runat="server">

</body>
Then on code behind,
bdy.Style["Background-Color"] = LightYellow;

How will i apply CSS class from Code behind?

Suppose i have a CSS class named Body_bk_color defined or written on page,then on code behind we will write as:

bdy.Style["Background-Color"] = "Body_bk_color";


Where bdy is our ID of the Body.
What is an alternate way of calling CSS class at run-time?

With the help of Attributes property of Controls we can call CSS class dynamically as:-
lbl_name.Attributes.Add("class","your class name");

txt_name.Attributes.Add("class","your class name");

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