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

What is the use of CausesValidation property in Asp.Net?

CausesValidation is a property used in Buttons i.e. Command button,Link button,Imagebutton which is used to prevent validation.
It ensures that whether validation should be performed or not.it has True/False value.When we have to perform any validation on button like Save button then we have to set it to true.
And when we do not have to perform validation in button like Delete,Reset,New then set this property to False.

For Example:
<asp:Button id="btn_delete" CausesValidation="False" runat="server" Text = "Delete" />

<asp:Button id="btn_save" CausesValidation="True" runat="server" Text = "Save"/>

Is there a possibility to override private virtual methods?

NOTE: This is objective type question, Please click question title for correct answer.
What is the use of throw and throw exception in .Net?

When we use "throw" statement, it preserves or gives us the original stack trace.
When we use "throw ex" statement, stack trace of the exception will be replaced with the stack trace starting at the re-throw point.
So, it is very important to use throw statement instead of throw ex statement as it gives more accurate stack trace.
How can you describe === operator?

The identically equal operator is represented by three equal signs "===" and returns true only if the operands are equal without
conversion, as in this example
Code:
var result1 = (“55” == 55); //true - equal because of conversion
var result2 = (“55” === 55); //false - not equal because different data.
Differentiate undefined value and NULL value?

Undefined value: If a value that is not defined and has no keyword then it is known as undefined. For example in the declaration, int num; the num has undefined value.
Null value: If a value that is explicitly specified by the keyword ‘null’ then it is known as null value. For example in the declaration, String str=null; the str has a null value.
How to fill DropDownList control from the Datasource?

We have to follow 4 steps for populating dropdownlist.

1st step:Attach datasource to dataset.
ddl_project.DataSource = ds_project.

2nd step:assign datatextfield property to column name
ddl_project.DataTextField = "project_name";

3rd step:assign datavaluefield property to column name
ddl_project.DataValueField = "project_id";

4th step:call databind method
ddl_project.DataBind();
How to show information on Server controls on mousemove?

We use the ToolTip property of any control to show information.Whenever we keep mouse pointer on control,then any information,which is set in ToolTip will display.

For Example:
<asp:button id="btn_save" runat="server" Tooltip="Save Record"/>

<asp:button id="btn_delete" runat="server" Tooltip="Delete Selected Record"/>

Explain few ScriptManager properties which are often used?

AsyncPostBackTimeout - Gets or sets the time in seconds before asynchronous postbacks time our if no response is received
ClientID - Gets the server control identifier generated by ASP.NET (The id for this control that is rendered on the page)
EnablePageMethods - Gets or sets whether public static page methods in asp.net page can be called from client script.
EnableViewState - Gets or sets a value that indicates whether server control persists its viewstate and the viewstate of its child control if any.
EnablePartialRendering - Gets or sets a value that enables partial rendering of a page, which in turn enables you to update regions of the page individually by using UpdatePanel controls.
How to provide the alternate text in a Image button or Image?

With the help of Image 'AlternateText property,we can provide the alternate text of the Image button or Image.

It displayed text in the Image control when the image is not available.Browsers that support the ToolTips feature display this text as a ToolTip.

For Example:
<asp:Image id="img_view" runat="server" AlternateText="View Selected Record" ImageAlign="left"

ImageUrl="images/view.jpg"/>


If view.jpg image is not present then View Selected Record will be displayed as ToolTip on Image.
What is an alternative to give AlternateText in Image?

With the help of alt attribute of an image ,we can give alternate text on image.

For Example:
<input type="img_view" name="submit" src="view.jpg" alt="Submit" />

Can you edit data in the Repeater control?

No,we cant edit its only for read the information from its data source ...
4.Is it possible to enter more than one line in a TextBox control?

Yes, it is possible to enter more than one line in a TextBox control. To do this, you need to set the Multiline property of the TextBox control to True. You can set this property at design time as we ll as runtime. The syntax to set this property at runtime is as follows:
Textbox1.Multiline = true;
What happens if a static constructor throws an exception?

If a static constructor throws an exception, the runtime will not invoke it a second time, and the type will remain uninitialized for the lifetime of the application domain in which your program is running.
Will this code compile? Does it? What does it mean? using System; class Test { enum Foo { Bar, Baz }; static void Main() { Foo f = 0.0; Console.WriteLine(f); } }

This shouldn't compile, but it does under the MS compilers for both C# 2 and 3 (and probably 1 as well - I haven't checked). It shouldn't compile because only the literal 0 should be implicitly convertible to the default value of any enum. Here the decimal is 0.0. Just a little compiler bug. The result is to print Bar as that's the 0 value of the Foo.
How do I get application full path & .exe?

string path = System.Reflection.Assembly.GetExecutingAssembly().Location.ToString();

It will return the full path and the name of the executable.

To get only the full path, you can use:
string pathOnly = Application.StartupPath.ToString();
How can you get the extension from a File upload control ?

var extension = System.IO.Path.GetExtension(FileUpload1.FileName);

Here, FileUpload1 is the name of the asp.net File upload control.
How to perform multiple file input?

<form method="post" action="upload.php" enctype="multipart/form-data">
<input name='uploads[]' type="file" multiple>
<input type="submit" value="Send">
</form>
How to stop flickering while the gets loaded in IE?

<!--[if IE]>

<meta http-equiv="Page-Enter" content="blendTrans(duration=0)" />
<meta http-equiv="Page-Exit" content="blendTrans(duration=0)" />
<![endif]-->

Global.asax file is mandatory in an application. True or False

NOTE: This is objective type question, Please click question title for correct answer.
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