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

How to specify the Tab index for Asp.Net control?

Every controls have TabIndex property,through which we can set controls tab order i.e. when we press Tab button from keyboard,then we can navigate from one control to another control.

For Example:-
<asp:TextBox ID="TextBox1" runat="server" TabIndex="0"></asp:TextBox>

<asp:TextBox ID="TextBox2" runat="server" TabIndex="1"></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Button" TabIndex="2" />

What is the type of TabIndex?

TabIndex has Integer type means we provide numeric value to TabIndex property.
From which integer value TabIndex will start?

NOTE: This is objective type question, Please click question title for correct answer.
Can we provide Negative value to TabIndex?

No,we can not,as it's always has positive value starting from zero-index.
If we do not provide TabIndex property to any controls,then will controls take TabIndex property values internally?

Yes,TabIndex property takes values as internally.Suppose we are designing page with Table attribute or tag,then all controls inside table tag will have tabindex property internally.
How to give focus to Textbox?

We have a Focus static method of TextBox control,through which we can set focus to TextBox at run-time.

For Example:-
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


On Code behind on page load event:-
TextBox1.Focus();

What is an alternate way of setting TextBox focus in design time?

We will set TabIndex property to 0 for setting textbox focus:

For Example:-
<asp:TextBox ID="TextBox1" runat="server" TabIndex="0"></asp:TextBox>

How to give tooltip on controls at design time?

Dot Net provides ToolTip property for controls to let us inform which controls have what functionality.

For Example:-
<asp:Button ID="btn_save" runat="server" Text="Save Record" ToolTip="Click to Save" />

<asp:Button ID="btn_delete" runat="server" Text="Delete Record" ToolTip="Delete Selected Records" />
<asp:Button ID="btn_reset" runat="server" Text="Reset" ToolTip="Clear Controls" />

How to assign ToolTip on controls dynamically?

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


On Page load,we will write:
btn_save.ToolTip = "Save Data";

What do we mean by Title HTML property attribute?

Title is an in-built property in HTML used for showing information when a mouse hovers on any control object.It's same as Tooltip text.

In short we can say that,Title is an alternate way of Tooltip property.

For Example:-
<p title="Click here to go to Dot Net Funda">http://www.dotnetfunda.com</p>

What is the difference between Tooltip and Title property?

Tooltip and Title both property is known to be shown information when a Mouse is hovers on any controls meaning that both is used for showing tooltip text.
But there is a little difference between them.
Tooltip is used in Server controls i.e. Asp.Net controls whereas Title is used in HTML controls .

For Example:-
<asp:Button ID="btn_save" runat="server" Text ="Save" ToolTip="Save Record" />

<input type ="button" value="Save" title="Save Record" />

How to select any controls and style with a Title attribute containing the word "View"?

This is done using [attribute~=value] selector attribute which is used to select elements with an attribute value containing a specified word.

For Example:-
<style type="text/css">

[title~=View]
{
border-color:blue;
}
</style>

<img src="img_view_details.jpg" title="View Details" width="20" height="15" />
<img src="img_flwr.gif" title="View Image" width="100" height="100" />

How to provide Border color to any controls?

With the help of BorderColor control' in-built property ,we can apply Border color to any controls.

For Example:-
<asp:Button ID="btn_save" runat="server" Text="Save" BorderColor="Yellow" />

<asp:TextBox ID="txt_name" runat="server" BorderColor="Pink"></asp:TextBox>

What is an alternative way of providing Border color to any controls?

We have border-color in-built STYLE property,which is used to apply Border color to any controls.

For Example:-
<asp:Button ID="btn_save" runat="server" Text="Save" style="border-color:yellow;" />

<asp:TextBox ID="txt_name" runat="server" style="border-color:yellow;"></asp:TextBox>

Can we call more then one CSS class on any controls?

YES,we can call.
Just give spaces in-between class names in CSSClass property.

For Example:-
<style type="text/css">

.border_color
{
border-color:yellow !important;
}
.font_bold
{
font-weight:bold !important;
color:blue;
}
</style>

<asp:Button ID="btn_save" runat="server" Text="Save" CssClass="border_color font_bold" />
<asp:TextBox ID="txt_name" runat="server" CssClass="font_bold border_color"></asp:TextBox>

What will happen if we provide BorderColor="Red" style="border-color:blue;" then which color will be applied to controls?

In that case,border color will be applied from style property only means it will discard or overwrite server controls BorderColor property and take in-line style property.
What is the difference between CSSClass and class property of controls?

Both are used for applying css classes to the controls but there is only one difference between both.
As we can write either CSSClass or class property for server side controls i.e. Asp.net controls but only use class property for HTML control.

For Example:-
<input type="button" id="btn1" value="Click Me" class="font_bold"/>        

<asp:Button ID="btn2" runat="server" Text="Click Me" class="font_bold"/>
<asp:Button ID="btn3" runat="server" Text="Click Me" CssClass="font_bold"/>

What value or color codes we can provide for color property?

We can provide hash(#) value or color name or RGB color in color property whether color is border-color,background color or font-color and anything.The values provided with hash are called color codes.

For Example:-
background-color:#00ff00;

background-color:green;
background-color:rgb(0,255,0);

What is the use of background color property in HTML?

The background-color is an in-built style property and is used for setting the back color or background color of any controls.The background of a controls is the total size of the controls,including padding and border.

For Example:-

<asp:Button ID="btn1" runat="server" Text="Click Me" style="background-color:palegreen;"/>
<div style="background-color:yellow;"></div>
<p style="background-color:blue;">Dot net Funda</p>

What is the default value for backgroundColor style property?

Transparent is the default value for backgroundColor property meaning that if we do not provide any color to backgroundColor property,then it takes Transparent color as default.
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