Blog Home  Home Feed your aggregator (RSS 2.0)  
Software Code Help blogs - Interview Question ASP.NET
newtelligence powered
 
 Friday, August 01, 2008

Use

Server.UrlEncode

Friday, August 01, 2008 1:50:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   C# | Interview Question ASP.NET  | 
 Thursday, July 31, 2008

1. OnInit (Init)  -- Inializes all Child controls on the Page

2. LoadControlState  -- Loads the Control State 

3. LoadViewState -- Loads the View State

4. LoadPostData -- Control properties are set according to the received form data

5. Load -- Actions can be performed on the controls as all the pre-activities are complete by this time

6. RaisePostDataChangedEvent -- This event is raised if data has been changed in previous and Current Postbacks.

7. RaisePostBackEvent -- This event handles the user action that caused the Postback.

8. PreRender (OnPreRender) -- This event takes place between postback and saving viewstate. Till this stage changes will be saved to the control.

9. SaveControlState -- Self Explanatory

10. SaveViewState -- Self Explanatory

11. Render -- Generates artifacts at Client side (HTML,DHTML,Scripts) to properly display controls

12. Dispose -- Releases unmanaged Resource ( Database connections, file handles)

13. Unload -- Releases managed Resources ( Instances created by CLR)

Thursday, July 31, 2008 1:47:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 
 Tuesday, July 01, 2008

You bet. Just call SetNoStore on the HttpCachePolicy object exposed through the Response object's Cache property, as demonstrated here:

 

 

<%@ Page Language="C#" %>
<html>
<body>
<%
Response.Cache.SetNoStore ();
Response.Write (DateTime.Now.ToLongTimeString ());
%>
</body>
</
html>

 

 

SetNoStore works by returning a Cache-Control: private, no-store header in the HTTP response. In this example, it prevents caching of a Web page that shows the current time.

Tuesday, July 01, 2008 11:24:24 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 

Most browsers recognize the following META tag as a signal to automatically refresh the page every nn seconds:

 

<meta http-equiv="Refresh" content="nn">

Here's an ASPX file that displays the current time of day. Once displayed, it automatically refreshes every 5 seconds:

 

<% Page Language="C#" %>
<meta http-equiv="Refresh" content="5">
<
html>
<body>
<%
Response.Write (DateTime.Now.ToLongTimeString ());
%>
</body>
</
html>

Tuesday, July 01, 2008 11:08:25 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 

Use the HtmlInputFile class, which you can declare an instance of with an <input type="file" runat="server"/> tag. The following example is a complete ASPX file that lets a user upload an image file and a comment descibing the image. The Upload_Click method writes the image and the comment to a table named Pictures in a SQL Server database named MyPictures.

<form id="Form2" enctype="multipart/form-data" runat="server">
<table>
<tr>
<td>File name</td>
<td><input type="file" id="Upload" runat="server" /></td>
</tr>
<tr>
<td>Comment</td>
<td><asp:TextBox ID="Comment" RunAt="server" /></td>
</tr>
<tr>
<td></td>
<td><asp:Button Text="Upload" OnClick="Upload_Click(" RunAt="server" /></td>
</tr>
</table>
</
form>

protected void Upload_Click(object sender, EventArgs e)
{
// Create a byte[] from the input file

int len = Upload.PostedFile.ContentLength;

byte[] pic = new byte[len];

Upload.PostedFile.InputStream.Read(pic, 0, len);

// Insert the image and comment into the database

SqlConnection connection = new SqlConnection("server=localhost;database=mypictures;uid=sa;pwd=");

try

{

connection.Open();

SqlCommand cmd = new SqlCommand("insert into Pictures " + "(Picture, Comment) values (@pic, @text)", connection);

cmd.Parameters.Add("@pic", pic);

cmd.Parameters.Add("@text", Comment.Text);

cmd.ExecuteNonQuery();

}

finally{
connection.Close();
}
}

Tuesday, July 01, 2008 11:02:22 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 
Copyright © 2009 Software Code Help. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: