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

Which statement is(are) correct about App_Code folder in Asp.Net?

NOTE: This is objective type question, Please click question title for correct answer.
How to automatically redirecting with refresh meta tag in Asp.Net?

We have to write the below code as following:-
<html>

<head>
<meta http-equiv="refresh" content="5;url=http://www.dotnetfunda.com/profilepage.aspx" />
<title>Meta Tag Refresh</title>
</head>
<body>

Every 5 seconds,page will refresh.
Which one is the Session-State Modes in Asp.Net?

NOTE: This is objective type question, Please click question title for correct answer.
How To get Referrer URL or the previous page url in ASP.NET?

We will use Request.UrlReferrer property to get previous page URL.
string Previous_Page_URL = Request.UrlReferrer.ToString();

Which variables are used to access throughout the form?

NOTE: This is objective type question, Please click question title for correct answer.
How to redirect to another page after definite seconds in Asp.Net by using Response Header class?

By Adding Meta Tag by appending Response Header,we can do:-
Response.AppendHeader("Refresh", "10;url=profile.aspx");

Label1.Text = "You will now be redirected in 10 seconds";

How to redirect to another page after definite seconds in Asp.Net by using HtmlMeta class?

Write below code:-
using System.Web.UI.HtmlControls;

HtmlMeta meta = new HtmlMeta();
meta.HttpEquiv = "Refresh";
meta.Content = "10;url=profile.aspx";
this.Page.Controls.Add(meta);
Label1.Text = "You will now be redirected in 10 seconds";

How to redirect to another page after definite seconds in Asp.Net in ASPX page in HEAD section?

The simplest way is to add the Meta tag directly to the ASPX page.

<head runat="server">

<meta http-equiv="Refresh" content="10;url=profile.aspx" />
</head>

Which directive is said to be placed at the top of all ASPX page?

NOTE: This is objective type question, Please click question title for correct answer.
Which directive is said to be placed at the top of all ASCX page?

NOTE: This is objective type question, Please click question title for correct answer.
Which property of dropdownlist or checkboxlist,listbox is used to fire their events?

NOTE: This is objective type question, Please click question title for correct answer.
How to upload multiple files in ASP.NET ?

In ASP.NET simultaneously on the server we can use multiple files to upload file

Example :
ASPX PAGE :
 Upload files<br />

<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:FileUpload ID="FileUpload2" runat="server" /><br />
<asp:FileUpload ID="FileUpload3" runat="server" /><br />
<asp:FileUpload ID="FileUpload4" runat="server" /><br />
<p><asp:Button ID="btnUpload" runat="server" Text="Upload Multiple Files" OnClick="UploadMultipleFiles" /></p>


Code behind :
protected void   UploadMultipleFiles(object sender, EventArgs e)

{
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];

string path = Server.MapPath("~/");
string fileName = file.FileName;
file.SaveAs(path + fileName);
Response.Write(fileName + " uploaded successfully ! <br />");
}
}

How to determine if the selected date is today’s date or weekend in ASP.NET ?

If we want to determine if the selected date is today’s date or a weekend.We can use this code

ASPX Page :
 <asp:Calendar runat="server" ID="Calendar2" OnDayRender="RenderDaysEvent" /> 


Code Behind:
protected void RenderDaysEvent(object sender, DayRenderEventArgs e)

{
if (e.Day.IsToday)
{
e.Cell.Controls.Add(new LiteralControl("<p style=\"color:brown;\">Today's date</p>"));
}
if (e.Day.IsWeekend)
{
e.Cell.Controls.Add(new LiteralControl("<p style=\"color:green;\">Weekend</p>"));
}
}


By using the IsToday and IsWeekend properties we can determine if a particular date is today’s date or weekend respectively and perform our operation
How do we disable the dates of other months in ASP.NET ?

If we want to disable the dates of other month so that those dates are not selectable .

ASPX PAGE :
<asp:Calendar runat="server" ID="Calendar1" OnDayRender="RenderDays" />


CODE BEHIND :
protected void RenderDays(object sender, DayRenderEventArgs e)

{
if (e.Day.IsOtherMonth)
{
e.Day.IsSelectable = false;
}
}


the RenderDays method that fires in OnDayRender event, we can check for the IsOtherMonth property of the day and if it is true we can set IsSelectable to false that disables the other month dates.
How to disable a specific date in the calender ?

If we want to disable a specific date of the calendar control so that it is not selectable.

ASPX PAGE :
<asp:Calendar runat="server" ID="Calendar1" OnDayRender="RenderDays" /> 


CODE BEHIND :
protected void RenderDays(object sender, DayRenderEventArgs e)

{
if (e.Day.DayNumberText.Equals("25"))
{
e.Day.IsSelectable = false;
}
}

we have specified the OnDayRender event of the Calendar control that fires RenderDays sever side method. we have found out the day that needs to disable and set its IsSelectable property to false.
How to specify the Selection mode so that user can select entire month, entire week in ASP.NET ?

If we want to provide option to the user to select entire week or month of the calendar.
ASPX PAGE:
<asp:Calendar ID="Calendar1" runat="server" SelectionMode="DayWeek"  />

The selection mode can be specified by setting the SelectionMode property of the Calendar control. By default the selection mode is “Day”.
How to apply css style in the Label control from code behind in Asp.net?

In Asp.Net Label COntrol of css style is done by using "FontColor BackColor FontSize by using these in the code behind we can change the Label in Css style.

For example :
Label3.Text="This this is the text written in the css style ";

Label.Font.Names=fontNames;
Label3.Font.size=FonyUnit.Larger;
Label3.ForeColor=system.Drawing.color.Blue;
Label3.Backcolor=system.Drawing.color.yellow;

Just use the above code to test the Css style Label Controlin asp.net
How to get a password type textbox in Asp.net ?

If we need to get a password text box so that the actual text doesn’t appear as user type in the text box, This is frequently used to enter password or secret code on the web page so that other can’t know what is being written in the textbox.
For example :
<p>Password: <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" /></p>


Use the above code to get the password type textbox.
How to make a text disable in ASP.Net?

If we want to make a text disabled we use disabled option, Then the written text is hidden in the text box that cannot be modified.Make sure that Enable option is in false,then disabled function runs.

For example
<asp:TextBox ID="TextBox4" runnat="server" Enabled="false" Text="Disabled"/>


By default,a .Net website is configured with which of the following authentication types ?

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