Monday 23 December 2013

Interview Questions & Answer on Master Pages

Q : What are Master Pages in ASP.NET? or What is a Master Page?
Ans : ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.
Q : What are the 2 important parts of a master page?
Ans : 
1. The Master Page itself
2. One or more Content Place holder
Q : Can Master Pages be more then one?
Ans : Yes.
Q : What is the file extension for a Master Page?
Ans : File extension for a Master Page is .master
Q : How do you identify a Master Page?
Ans : The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages.
Q : Can a Master Page have more than one ContentPlaceHolder?
Ans : Yes.
Q : What is a ContentPlaceHolder?
Ans : ContentPlaceHolder is a region where replaceable content will appear.
Q : How do you bind a Content Page to a Master Page?
Ans : MasterPageFile attribute of a content page's @ Page directive is used to bind a Content Page to a Master Page.
Q : Can the content page contain any other markup outside of the Content control?
Ans : No.
Q : What are the advantages of using Master Pages?
Ans : 1. They allow you to centralize the common functionality of your pages so that you can make updates in just one place.
2. They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.
3. They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered.
4. They provide an object model that allows you to customize the master page from individual content pages.
Q : What are the 3 levels at which content pages can be attached to Master Page?
Ans : At the page level - You can use a page directive in each content page to bind it to a master page.
At the application level - By making a setting in the pages element of the application's configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page.
At the folder level - This strategy is like binding at the application level, except that you make the setting in a Web.config file in one folder only. The master-page bindings then apply to the ASP.NET pages in that folder.
Q : What is @MasterType directive used for?
Ans : @MasterType directive is used to create a strongly typed reference to the master page.
Q : Are controls on the master page accessible to content page code?
Ans : Yes, controls on the master page are accessible to content page code.
Q : At what stage of page processing master page and content page are merged?
Ans : During the initialization stage of page processing, master page and content page are merged.
Q : Can you dynaimically assign a Master Page?
Ans : Yes, you can assign a master page dynamically during the PreInit stage using the Page class MasterPageFile property as shown in the code sample below.
void Page_PreInit(Object sender, EventArgs e)
{
this.MasterPageFile = "~/MasterPage.master";
}
Q : Can you access non public properties and non public methods of a master page inside a content page?
Ans : No, the properties and methods of a master page must be public in order to access them on the content page.

Q : Can you access controls on the Master Page without using FindControl() method?
Ans : Yes, by casting the Master to your MasterPage as shown in the below code sample.
protected void Page_Load(object sender, EventArgs e)
{
MyMasterPage MMP = this.Master;
MMP.MyTextBox.Text = "Text Box Found";
}

Interview Question on Asp.Net

                                                                                                                                                Next.....

What is Asp.Net:- Asp.net is abbreviated as "Active Server Pages .Network enable technology".
Active-An ASP page provides dynamic content that's updated every time that is accessed.
Server- An ASP page contains script code that the Web server executes.
Pages-An ASP page is a Web page that the user navigates to and is displayed in his or her browser.

How many types of Validation control in Asp.Net:- 
  • Required Field Validator
  • Range Validator
  • Compare Validator
  • Regular Expression Validator
  • Custom Validator
  • Validation Summary

Required Field Validator:-It checks whether the control have any value. It is used when you want the control should not be empty.
Range Validator:-It checks if the value in validated controls is in that specific range.
Compare Validator:-It checks that the value in controls should match some specific value.
Regular Expression Validator:-When we want the control, value should match with a specific regular expression.
Custom Validator:-It is used to define user defined validation.
Validation Summary:-It displays summary of all current validation errors on an Asp.Net page.

How can you redirect user to different page.

By Useing the Response.Redirect method to direct users to different pages.

How can you redirect user to same page.

By Useing the Server.Transfer method to direct users to different pages.

SqlConnection in Web Configuration File :-

(1) Connection when username and password exist

<connection string>
<Add="Connect"connectionString="server=Servername;database=databasename;uid=username;pwd=password" providerName="system.data.sqlclient"/>
</connectionstring>
(2) Connection by using web authentication:-
<connection string>
<Add="Connect"connectionString="server=Servername;database=databasename;Integrated Security=True" providerName="system.data.sqlclient"/>
</connectionstring>

Authentication :-It is verifying the identity of a user.
Authorization :- It is the process where we check does this identity have access right to the system

How many Types of Authentication Technique in Asp.Net 

There are three types of Authentication techniques are :
  • Windows Authentication
  • Passport Authentication
  • Form Authentication
Window Authentication:- It is generally use if the resources the application belong to same organisation. Example:Internet Web application.

Passport Authentication:-It is based on the passport website provided by microsoft So when user login with credentials it will be  reached to the passport website (i.e. hotamil,window live) where authentication will happen.If authentication is successful it will return a token to your website.

Form Authentication:- This is cookies based authentication where password and username are stored on the client machines as cookies file or they are sent through URL for every request Form-Based authentication present the with an HTML-based web page that prompts the user for credential. Ex. Commercial website

Anonymous Access:- I we do not want any type of authentication then we will use Anonymous access.
      Ex-Public internet web application. 
What are the five different ways of handling state in ASP.Net Web forms?
State management Technique is a process by which we maintain the state & page into over multiple request for the same of different page.

The Sequence in which Asp.Net Event occurs

  • Page Init
  • Page Load
  • Control Event
  • Page Unload Event

 ASP.NET different from ASP Click here

 What ASP.NET class reads the contents of a form after the user clicks the Submit button?
The HttpResponse class reads the content of the form. You access this class using the Response object, where you can use the Form or Parameters collection to find each form entry.

                                                                                                                                                    Next.....

Sunday 22 December 2013

sql_quickref

SQL Quick Reference


SQL Statement
Syntax
AND / OR
SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition
ALTER TABLE
ALTER TABLE table_name 
ADD column_name datatype
or
ALTER TABLE table_name 
DROP COLUMN column_name
AS (alias)
SELECT column_name AS column_alias
FROM table_name
or
SELECT column_name
FROM table_name  AS table_alias
BETWEEN
SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2
CREATE DATABASE
CREATE DATABASE database_name
CREATE TABLE
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name2 data_type,
...
)
CREATE INDEX
CREATE INDEX index_name
ON table_name (column_name)
or
CREATE UNIQUE INDEX index_name
ON table_name (column_name)
CREATE VIEW
CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition
DELETE
DELETE FROM table_name
WHERE some_column=some_value
or
DELETE FROM table_name 
(Note:
 Deletes the entire table!!)
DELETE * FROM table_name 
(Note:
 Deletes the entire table!!)
DROP DATABASE
DROP DATABASE database_name
DROP INDEX
DROP INDEX table_name.index_name (SQL Server)
DROP INDEX index_name ON table_name (MS Access)
DROP INDEX index_name (DB2/Oracle)
ALTER TABLE table_name
DROP INDEX index_name (MySQL)
DROP TABLE
DROP TABLE table_name
GROUP BY
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value
IN
SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)
INSERT INTO
INSERT INTO table_name
VALUES (value1, value2, value3,....)
or
INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,....)
INNER JOIN
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
 
ON table_name1.column_name=table_name2.column_name
LEFT JOIN
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
 
ON table_name1.column_name=table_name2.column_name
RIGHT JOIN
SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
 
ON table_name1.column_name=table_name2.column_name
FULL JOIN
SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
 
ON table_name1.column_name=table_name2.column_name
LIKE
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern
ORDER BY
SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]
SELECT
SELECT column_name(s)
FROM table_name
SELECT *
SELECT *
FROM table_name
SELECT DISTINCT
SELECT DISTINCT column_name(s)
FROM table_name
SELECT INTO
SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_name
or
SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name
SELECT TOP
SELECT TOP number|percent column_name(s)
FROM table_name
TRUNCATE TABLE
TRUNCATE TABLE table_name
UNION
SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
UNION ALL
SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
UPDATE
UPDATE table_name
SET column1=value, column2=value,...
WHERE some_column=some_value
WHERE
SELECT column_name(s)
FROM table_name
WHERE column_name operator value

You can also this quick ref Query from this link..

Sql Function

SQL has many built-in functions for performing calculations on data.

SQL Aggregate Functions

SQL aggregate functions return a single value, calculated from values in a column.
Useful aggregate functions:
  • AVG() - Returns the average value
  • COUNT() - Returns the number of rows
  • FIRST() - Returns the first value
  • LAST() - Returns the last value
  • MAX() - Returns the largest value
  • MIN() - Returns the smallest value
  • SUM() - Returns the sum

SQL Scalar functions

SQL scalar functions return a single value, based on the input value.
Useful scalar functions:
  • UCASE() - Converts a field to upper case
  • LCASE() - Converts a field to lower case
  • MID() - Extract characters from a text field
  • LEN() - Returns the length of a text field
  • ROUND() - Rounds a numeric field to the number of decimals specified
  • NOW() - Returns the current system date and time
  • FORMAT() - Formats how a field is to be displayed

The AVG() Function

The AVG() function returns the average value of a numeric column.

SQL AVG() Syntax

SELECT AVG(column_name) FROM table_name

SQL COUNT(column_name) Syntax

The COUNT() function returns the number of rows that matches a specified criteria.

The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:
SELECT COUNT(column_name) FROM table_name;

SQL COUNT(*) Syntax

The COUNT(*) function returns the number of records in a table:
SELECT COUNT(*) FROM table_name;

SQL COUNT(DISTINCT column_name) Syntax

The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column:
SELECT COUNT(DISTINCT column_name) FROM table_name;
Note: COUNT(DISTINCT) works with ORACLE and Microsoft SQL Server, but not with Microsoft Access.

The FIRST() Function

The FIRST() function returns the first value of the selected column.

SQL FIRST() Syntax


SELECT FIRST(column_name) FROM table_name;

The LAST() Function

The LAST() function returns the last value of the selected column.

SQL LAST() Syntax

SELECT LAST(column_name) FROM table_name;

The MAX() Function

The MAX() function returns the largest value of the selected column.

SQL MAX() Syntax

SELECT MAX(column_name) FROM table_name;

The MIN() Function

The MIN() function returns the smallest value of the selected column.

SQL MIN() Syntax

SELECT MIN(column_name) FROM table_name;

The SUM() Function

The SUM() function returns the total sum of a numeric column.

SQL SUM() Syntax

SELECT SUM(column_name) FROM table_name;

The GROUP BY Statement

Aggregate functions often need an added GROUP BY statement.

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.

SQL GROUP BY Syntax

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name;

The HAVING Clause

The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions.

SQL HAVING Syntax

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;

The UCASE() Function

The UCASE() function converts the value of a field to uppercase.

SQL UCASE() Syntax

SELECT UCASE(column_name) FROM table_name;

Syntax for SQL Server

SELECT UPPER(column_name) FROM table_name;

The LCASE() Function

The LCASE() function converts the value of a field to lowercase.

SQL LCASE() Syntax

SELECT LCASE(column_name) FROM table_name;

Syntax for SQL Server

SELECT LOWER(column_name) FROM table_name;

The MID() Function

The MID() function is used to extract characters from a text field.

SQL MID() Syntax

SELECT MID(column_name,start[,length]) AS some_name FROM table_name;

The LEN() Function

The LEN() function returns the length of the value in a text field.

SQL LEN() Syntax

SELECT LEN(column_name) FROM table_name;

The ROUND() Function

The ROUND() function is used to round a numeric field to the number of decimals specified.

SQL ROUND() Syntax

SELECT ROUND(column_name,decimals) FROM table_name;

The NOW() Function

The NOW() function returns the current system date and time.

SQL NOW() Syntax

SELECT NOW() FROM table_name;

The FORMAT() Function

The FORMAT() function is used to format how a field is to be displayed.

SQL FORMAT() Syntax

SELECT FORMAT(column_name,format) FROM table_name;


C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...