Pages

Ads 468x60px

For New Update Use this Link http://dotnethubs.blogspot.in/ Offer for you

.

Monday 15 April 2013

Difference Between Query String and Session and Cookies


Difference Between Query String and Session and Cookies
Querystring Session
Querystring is client side state management technique. Session is server side state management technique.
Querystring data is page specific i.e. can be accessed in that page only. Session data can be accessed throughout the session.
Querystring data is visible to user and can be seen in browser url. Session data is not visible to user.
Data is not secured and can be altered hence insensitive data is stored in querystring. Data is secured hence sensitive data such as user information is stored.
Querystring has constraint of Maxlength. Session does not have such constraint.

Difference between Query string and Cookies

cookies is a text file stored on client machine when we surf ant thing on internet by the server automatically we dont have to create it

query string is used to transfer data from 1 page to anothe but this is not safe s it shows in url what data we r sending
pen any site and see url after question mark tht is url

Cookies: - Cookies are little pieces of information that a server stores on a browser. They are of two types
1. Temporary cookie
2. Persistent cookie

Temporary cookie: - They are also known as session cookies. These are volatile in nature. When the browser is shutdown they are erased.

Persistent cookie:- These may be called as permanent cookies. These are especially saved in files. It may remain for a month or year.

Properties of cookies
Some properties of cookie
Name: - represent the name of cookie.
Name value: - represent a collection of key values of cookie
Domain: - represent the domain associated with a specific cookie.
Path: - the path associated with a cookie.
Expires: - expired time of cookie.
Hashkey: - identifies whether the cookie is a cookie dictionary.
Secure: - specifies whether the cookie is to be sent in an encrypted connection or not


Query string is the limited way to pass information to the web server while Transferring from one page to another page. This information is passed in url of the request. see below the code sample


Code Sample

//Retrieving values from query string
String name;
//Retrieving from query string
name = Request.Param["umar"].ToString();

But remember that many browsers impose a limit of 255 characters in query strings. You need to use HTTP-Get method to post a page to server otherwise query string values will not be available.

Difference between Session and Cookies

The basic and main difference between cookie and session is that cookies are stored in the user's browser but sessions can't store in user's browser. This specifies which is best used for.

• A cookie can keep all the information in the client's browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie.

• Sessions are not reliant on the user allowing a cookie. They work like a token in the browser which allowing access and passing information while the user has opened his browser. The problem in sessions is when you close the browser the session will automatically lost. So, if you had a site requiring a login, this couldn't be saved as a session but it can be saved as a cookie, and the user has to re-login every time they visit.

Sunday 14 April 2013

what is authentication and authorization in .net

asp.net state management/session interview questions answer
Authentication: - prove genuineness

Authorization: - process of granting approval or permission on resources.

The same dictionary meaning applies to ASP.NET as well. In ASP.NET authentication means to identify the user or in other words its nothing but to validate that he exists in your database and he is the proper user.
Authorization means does he have access to a particular resource on the IIS website. A resource can be an ASP.NET web page, media files (MP4, GIF, JPEG etc), compressed file (ZIP, RAR) etc.
So the first process which happens is authentication and then authorization. Below is a simple graphical representation of authentication and authorization. So when the user enters ‘userid’ and ‘password’ he is first authenticated and identified by the user name.
Now when the user starts accessing resources like pages, ASPDOTNETauthentication, videos etc, he is checked whether he has the necessary access for the resources. The process of identifying the rights for resources is termed as ‘Authorization’.
To put it in simple words to identify “he is shiv” is authentication and to identify that “Shiv is admin” is authorization.

Detecting authentication and authorization: - The principal and identity objects
 

At any moment of time if you want to know who the user is and what kind of authentication type he using you can use the identity object. If you want to know what kind of roles it’s associated with then we need to use the principal object. In other words to get authentication details we need to the identity object and to know about authorization details of that identity we need the principal object.

For instance below is a simple sample code which shows how to use identity and principal object to display name and check roles.

difference between form authentication and windows authentication asp net

asp.net state management/session interview questions answer
ASP.NET has ways to Authenticate a user:
1) Forms Authentication :-
 Form authentication is used for internet and intranet based application.
This is provided so that web pages can make use of the local Windows User and Groups .

2) Windows Authentication :-
Windows authentication is the default authentication provided by the .net framework.


Windows Authentication provider is the default authentication provider for ASP.NET applications. When a user using this authentication logs in to an application, the credentials are matched with the Windows domain through IIS.


There are 4 types of Windows Authentication methods:
1) Anonymous Authentication - IIS allows any user
2) Basic Authentication - A windows username and password has to be sent across the network (in plain text format, hence not very secure).
3) Digest Authentication - Same as Basic Authentication, but the credentials are encrypted. Works only on IE 5 or above
4) Integrated Windows Authentication - Relies on Kerberos technology, with strong credential encryption



Forms Authentication
- This authentication relies on code written by a developer, where credentials are matched against a database. Credentials are entered on web forms, and are matched with the database table that contains the user information.
 ---------------------------------------------------------------------------------------------------------
Authentication And Authorization
Authentication is the process of identification and validation of a user's credentials. After the identity is authenticated,
a process called authorization determines whether that identity has access to a particular resource.
ASP.NET provides three ways to authenticate a user:
Forms authentication
Windows authentication
Passport authentication

Setting in web.config file given below

Forms authentication
<configuration>
<system.web>
<authentication mode="Forms"/>
<forms name="login"loginUrl="loginPage.aspx" />
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>

Windows authentication
<authentication mode="Windows"/>
<authorization>
<allow users ="*" />
</authorization>

Passport authentication
<configuration>
<system.web>
<authenticationmode="Passport">
<passportredirectUrl="loginPage.aspx" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</configuration>

df

asp.net state management/session interview questions answer

asp.net state management/session interview questions answer
1).What is state management?
Ans: State management is the process by which you maintain state and page information over multiple requests for the same or different pages.

2).Http is stateless, What does this mean?
Ans: Stateless protocol is a communications protocol that treats each request as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of requests and responses.

3).What is Session?
Ans: We know that Http is stateless, means when we open a webpage and fill some information and then move to next page then the data which we have entered will lost.
It happed do to Http protocol stateless nature. So here session come into existence, Session provide us the way of storing data in server memory. So you can store your page data into server
memory and retrieve it back during page postbacks.

4).What are the Advantage and disadvantage of Session?
Ans: Advantages:
Session provide us the way of maintain user state/data.
It is very easy to implement.
One big advantage of session is that we can store any kind of object in it. :eg, datatabe, dataset.. etc
By using session we don't need to worry about data collesp, because it store every client data separately.
Session is secure and transparent from the user.
Disadvantages:
Performance overhead in case of large volumes of data/user, because session data is stored in server memory.
Overhead involved in serializing and de-serializing session data, because in the case of StateServer and SQLServer session modes, we need to serialize the objects before storing them.

5).What is Session ID in Asp.net?
Ans: Asp.Net use 120 bit identifier to track each session. This is secure enough and can't be reverse engineered. When client communicate with server, only session id is transmitted, between them. When client request for data, ASP.NET looks on to session ID and retrieves corresponding data.

6).By default where the sessions ID's are stored ?
Ans: By default, the unique identifier for a session is stored in a non-expiring session cookie in the browser. You can specify that session identifiers not be stored in a cookie by setting the cookieless attribute to true in the sessionState configuration element.
We can also configure our application to store it in the url by specifying a "cookieless" session
The ASP Session cookie has this format:-
ASPSESSIONIDACSSDCCC=APHELKLDMNKNIOJONJACDHFN


7).Where does session stored if cookie is disabled on client’s machine?
Ans: If you want to disable the use of cookies in your ASP.NET application and still make use of session state, you can configure your application to store the session identifier in the URL instead of a cookie by setting the cookieless attribute of the sessionState configuration element to true, or to UseUri, in the Web.config file for your application.
The following code example shows a Web.config file that configures session state to use cookieless session identifiers.

Code:
<configuration>
  <system.web>
    <sessionState
      cookieless="true"
      regenerateExpiredSessionId="true"
      timeout="30" />
  </system.web>
</configuration>

8).Can you describe all the property set in web.config under session state?
Ans:
Code:
<configuration>
  <sessionstate
      mode="inproc"
      cookieless="false"
      timeout="20"
      sqlconnectionstring="data source=127.0.0.1;user id=<user id>;password=<password>"
      server="127.0.0.1"
      port="42424"
  />

</configuration>
Mode: The mode setting supports three options: inproc, sqlserver, and stateserver. As stated earlier, ASP.NET supports two modes: in process and out of process. There are also two options for out-of-process state management: memory based (stateserver), and SQL Server based (sqlserver). We'll discuss implementing these options shortly.
Cookieless: The cookieless option for ASP.NET is configured with this simple Boolean setting.
Timeout: This option controls the length of time a session is considered valid. The session timeout is a sliding value; on each request the timeout period is set to the current time plus the timeout value
Sqlconnectionstring: The sqlconnectionstring identifies the database connection string that names the database used for mode sqlserver.
Server: In the out-of-process mode stateserver, it names the server that is running the required Windows NT service: ASPState.
Port: The port setting, which accompanies the server setting, identifies the port number that corresponds to the server setting for mode stateserver.

9).What are Session Events?
Ans: There are two types of session events available in ASP.NET:
Session_Start
Session_End
You can handle both these events in the global.asax file of your web application. When a new session initiates, the session_start event is raised, and the Session_End event raised when a session is abandoned or expires.

10).How you can disable session?
Ans: If we set session Mode="off" in web.config, session will be disabled in the application. For this, we need to configure web.config the following way:
Code:
<configuration>
  <sessionstate  Mode="off"/>
</configuration>

Saturday 13 April 2013

latest interview questions on asp net c# for 2 years experience

latest interview questions on asp net c# for 2 years experience
Introduction :-
I have collected the best asp.net and c#.net question with answer for experience person who have two [2] years of experience in asp.net and c#.net.
Firstly any enterviewer ask to you

1 :-  How is Felling know ?
Asn :- Good ,Felling well like this you give the answer

2  :- Tell me about your self in brief ?
Good morning sir/madam.

This is Chitranjan Singh Rathore

My educational qualification are:

I have completed my 10th standard in 2002 from  Little flower school and also 12th standard in 2004.

I have completed my graduation in 2007 from Holkar science college.

I have completed my post graduation in 2010 from Medicaps Colloege indore .

Coming to my family background.

My father is a private employee in banking sector.

My mother is a housewife.

I have 1 elder sister and 2 elder brother.

My personal details are.

My strength are hardworking and truth person.

My weakness are emotional and a little shy.

My hobbies are playing cricket and indoor games.

Thank you.
3 :- What is asp.net life cycle ?

Life Cycle Events

PreInit

The properties like IsPostBack have been set at this time.

This event will be used when we want to:

  1. Set master page dynamically.
  2. Set theme dynamically.
  3. Read or set profile property values.
  4. This event is also preferred if want to create any dynamic controls.
Init
  1. Raised after all the controls have been initialized with their default values and any skin settings have been applied.
  2. Fired for individual controls first and then for page.
LoadViewState
  1. Fires only if IsPostBack is true.
  2. Values stored in HiddenField with id as _ViewState decoded and stored into corresponding controls.
LoadPostData

Some controls like:

  1. Fires only if IsPostBack is true.
  2. Some controls like Textbox are implemented from IPostBackDataHandler and this fires only for such controls.
  3. In this event page processes postback data included in the request object pass it to the respective controls.
PreLoad
  • Used only if want to inject logic before actual page load starts.
Load
  • Used normally to perform tasks which are common to all requests, such as setting up a database query.
Control events
  1. This event is fired when IsPostBack is true.
  2. Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.
PreRenderRaised after the page object has created all the controls that are required for rendering which includes child controls and composite controls.
  1. Use the event to make final changes to the contents of the page or its controls before the values are stored into the viewstate and the rendering stage begins.
  2. Mainly used when we want to inject custom JavaScript logic.
SaveViewState
  • All the control values that support viewstate are encoded and stored into the viewstate.
RenderGenerates output (HTML) to be rendered at the client side.
  • We can add custom HTML to the output if we want here.
Unload
  1. Fired for individual controls first and then for page.
  2. Used to perform cleanup work like closing open files and database connections.

5 :- How the request is handled by IIS ?

We give an URL to an aspx page in the browser address bar and press enter. What happens next? We get the response in terms of rendered HTML but how?
  1. We are requesting something from the browser, which means indirectly we are requesting something from the Web Server, that means IIS. IIS, based on the file extension, decides which ISAPI extension can serve the request.

    And in case of ASP.Net (.aspx) it will be aspnet_isapi_dll so the request is passed to it for processing.
     
  2. When the first request comes to the website,

    an application domain is created by the ApplicationManager class where exactly the website runs, and which creates an isolation between 2 web applications.
    Within the application domain an instance of the HostingEnvironment class is created which provides access information about the application such as the name of the folder where the application is stored.
     
  3. Next ASP.Net creates core objects like HttpContext, HttpRequest,HttpResponse.
     
  4. Finally the application starts by creating an instance of the HttpApplication Class (which can be reused for multiple requests to maximize performance).
6 :- difference between form authentication and windows authentication asp net ?
ans - Click Here
 difference between form authentication and windows authentication asp net 

7 :- what is authentication and authorization in .net ? 
ans :- Click Here 
what is authentication and authorization in .net

8 :- What is Difference between Session and Cookies  ? 

The basic and main difference between cookie and session is that cookies are stored in the user's browser but sessions can't store in user's browser. This specifies which is best used for.

• A cookie can keep all the information in the client's browser until deleted. If a person has a login and password, this can be set as a cookie in their browser so they do not have to re-login to your website every time they visit. You can store almost anything in a browser cookie.

• Sessions are not reliant on the user allowing a cookie. They work like a token in the browser which allowing access and passing information while the user has opened his browser. The problem in sessions is when you close the browser the session will automatically lost. So, if you had a site requiring a login, this couldn't be saved as a session but it can be saved as a cookie, and the user has to re-login every time they visit.
cookies are nothing but a small piece of information on the client machine. before we create a cookies we should check whether the cookies are allowed at the browser side. They are limited in a size 4k.(they are 2 types of cookies peristant cookie , and session cookies)

Sessions cookies are stored in a server memory during the client browser session.When the browser is closed the session cookies are lost.

9 :-Advantages and disadvantages of Session?
Following are the basic advantages and disadvantages of using session. I have describe in details with each type of session at later point of time.

Advantages:

  • It helps maintain user state and data all over the application.
  • It is easy to implement and we can store any kind of object.
  • Stores client data separately.
  • Session is secure and transparent from the user.

Disadvantages:

  • Performance overhead in case of large volumes of data/user, because session data is stored in server memory.
  • Overhead involved in serializing and de-serializing session data, because in the case of StateServer and SQLServer session modes, we need to serialize the objects before storing them.
Besides these, there are many advantages and disadvantages of session that are based on the session type. I have discussed all of them in the respective sections below.

Friday 12 April 2013

asp net with mysql database connection

asp net with mysql database connection
Introduction-:
Connect to asp.net and c#.net with page your database firstly you have to download the Connector
from this link
My Sql to Asp.net Connector Link 
another second link you can download the mysql dotnet connector directly
Mysql to Asp.net Connector Direct Link 
 It is very  essay for use asp.net or c#.net with Mysql database

1-: Firstly you have to download the set file for mysql connector with DOTNET
2:- Install the setup file

Wednesday 10 April 2013

Public static void main String arg means?

Public static void main String arg means?

  Catergoies-: how to install and configure the tomcat server

                      How to reset IIS with the command Prompt

Introduction:

public static void main(String args[])
{
      
}

Public-:  
   The public keyword is an access specifier, which allows the programmer to control the visibility of class members. When a class member is preceded by public, then that member may be accessed by code outside the class in which it is declared.In this case, main( ) must be declared as public, since it must be called by code outside of its class when the program is started.
Static -:  
   The keyword static allows main( ) to be called without having to instantiate a particular instance of the class. This is necessary since main( ) is called by the Java interpreter before any objects are made.
Void -:     
  The keyword void simply tells the compiler that main( ) does not return a value. As you will see, methods may also return values.

main( )-:  
 As stated, main( ) is the method called when a Java application begins. Keep in mind that Java is case-sensitive. Thus, Main is different from main. It is important to understand that the Java compiler will compile classes that do not contain a main( ) method. But the Java interpreter has no way to run these classes. So, if you had typed Main instead of main, the compiler would still compile your program. However, the Java interpreter would report an error because it would be unable to find the main( ) method.

String args[]-:
String args[ ] declares a parameter named args, which is an array of instances of the class String. Objects of type String store character strings.

args-: 
'args' stands for arguments. These are the arguments sent to the main method. Usually they are command line arguments.
For an example of how they are used, we will assume your program is called HelloWorld.

So when you want to run the program you would normally type:
java HelloWorld
and the program runs and displays the string "Hello World" to the console.

Now, you could set it up so the person who runs the program can include their name. You could use a command line argument to have the name come into the program, like so.
java HelloWorld Mark
Then your program will display this to the console.
Hello World Mark

So you would have something like this in your program.
public static void main(String[] args) {

System.out.print("Hello World");

if (args.length > 0) { // Checks if any arguments are present.
System.out.print(" " + args[0]);
}
}

Since args is an array, the first item in the array will be a string of "Mark". You access the first item with the number 0.

Now, for a slightly harder example. Just say you wanted the program to display "Hello World" if the user did not enter a name, and "Hello <the name>" is someone entered the name. You could do something like this.

public static void main(String[] args) {

System.out.print("Hello ");
if (args.length > 0) {
System.out.println(args[0]);
} else {
System.out.println("World");
}
}

Tuesday 9 April 2013

how to install and configure the tomcat server

how to install and configure the tomcat server

Introduction:

Tomcat is an application server from the Apache Software Foundation that executes Java servlets and renders Web pages that include Java Server Page coding ...
Steps involved in installation and configuration process for Tomcat 6.0.10 are illustrated below:
 
Step 1: Installation of JDK:  Don't forget to install JDK on your system (if  not installed) because any tomcat requires the  Java 1.5 (Java 5) and Java 1.6 (Java 6) and then set the class path (environment variable) of JDK.
Step 2: Setting the class path variable for JDK: Two methods are there to set the classpath.
  1. Set the class path using the following command.

    set PATH="C:\Program Files\Java\jdk1.5.0_08\bin";%PATH%
  2. The other way of setting the class path variable is:
First right click on the My Computer->properties->advance->Environment Variables->path.
Set bin directory path of JDK in the path variable.

Step 3: Now it's time to shift on to the installation process of  Tomcat 6.0.10. It takes various steps for installing and configuring the Tomcat 6.0.
For Windows, Tomcat comes in two forms :  .zip file and the Windows installer (.exe file). Here we are exploring the installation process by using the .exe file.  The directory C:\apache-tomcat-6.0.10 is the  common installation directory as it is pre-specified C:\ as the top-level directory. First unpack the zipped file and simply execute the .exe file.


The above shown screen shot is the first one shown in the installation process. Just click on the Next button to proceed the installation process.

click  "I Agree"  button to continue the installation process.

Click next to go with  the default components choosen. 

Choose the location for the Tomcat files as per your convenience. You can also choose the default location.

Now choose the port number on which you want to run the tomcat server. Tomcat uses the port number 8080 as its default value. But  Most of the people change the port number to 80 because in this case the user is not required to specify the port number at request time. But we are using here the default port number as 8080.  Choose the user name and password as per your convenience. We can change the port number even the installation process is over.  For that,  go to the specified location as " Tomcat 6.0 \conf \server.xml ". Within the server.xml file choose "Connector" tag and change the port number. 
e.g While using the port number 8080, give the following request in the address bar as:
Default Port: http//localhost:8080/index.jsp
In case of port number number 80 just type the string illustrated below in the address bar:
New Port: http://localhost/index.jsp
Note that we do no need to specify any port number in the URL.
Now click on the Next button to proceed the installation process.
The installation process shows the above screen as the next window. This window asks for the location of the  installed Java Virtual Machine. Browse the location of the JRE folder and click on the Install button. This will install the Apache tomcat at the specified location.

To get the information about installer click on the "Show details" button.

After completion of  installation process it will display the window like the above one.

On clicking at Finish button, a window like the above one will display a message printed on the window given below.

After successfully installing, a shortcut icon to start the tomcat server appears in the icon tray of the task bar as shown above. Double clicking the icon, displays the window of Apache Manager for Tomcat. It will show the "Startup type" as manual since we have changed the destination folder for tomcat during the installation process. Now we can configure the other options like "Display name" and "Description" .We can also start, stop and restart the service from here.

If  installation process completes successfully then a window as shown below will appear.


Now , set the environment variable for tomcat :
Step 4: Setting the JAVA_HOME Variable: Purpose of setting the environment variable JAVA_HOME is to specify the location of the java run time environment needed to support  the Tomcat else Tomcat server does not run.  This variable contains the path of  JDK installation directory. Note that  it should not contain the path up to bin folder.

set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_08

Here, we have taken the URI path according to our installation convention

For Windows XP, Go through the following steps:

Start menu->Control Panel->System->Advanced tab->Environment Variables->New->set the Variable Name as  JAVA_HOME and Variable Value as C:\Program Files\Java\jdk1.6.0 and then click on all the three ok buttons one by one. It will set the JDK path.

For Windows 2000 and NT, follow these steps:

Start->Settings->Control Panel->System->Environment Variable->New->set the Variable Name as JAVA_HOME and Variable Value as  C:\Program Files\Java\jdk1.6.0 and then click on all the three ok button one by one. It will set the JDK path

Now , Start the Tomcat Server :  Start the tomcat server from the bin folder of  Tomcat 6.0 directory by double clicking the " tomcat6.exe "  file. You can also create a shortcut of this .exe file at your desktop.

Stop the Tomcat Server: Stop the server by pressing the "Ctrl + c" keys.

Saturday 6 April 2013

seven important facts about asp net

seven important facts about asp net
Categories-:
 Asp.net Interview Questions And Answers
C#.Net Interview Questions And Answers

Fact 1: ASP.NET Is Integrated with the .NET Framework

The .NET Framework is divided into an almost painstaking collection of functional parts, with a staggering total of more than 7,000 types (the .NET term for classes, structures, interfaces, and other core programming ingredients). Before you can program any type of .NET application, you need a basic understanding of those parts—and an understanding of why things are organized the way they are.
The massive collection of functionality that the .NET Framework provides is organized in a way that traditional Windows programmers will see as a happy improvement. Each one of the thousands of classes in the .NET Framework is grouped into a logical, hierarchical container called a namespace. Different namespaces provide different features. Taken together, the .NET namespaces offer functionality for nearly every aspect of distributed development from message queuing to security. This massive toolkit is called the class library.
Fact 2:ASP.NET Is Compiled, Not Interpreted


One of the major reasons for performance degradation in classic ASP pages is its use of interpreted script code. Every time an ASP page is executed, a scripting host on the web server needs to interpret the script code and translate it to lower-level machine code, line by line. This process is visibly slow.



ASP.NET applications are always compiled - in fact, it’s impossible to execute C# or Visual Basic code without it being compiled first.







Fact 3: ASP.NET Is Multilanguage


With ASP.NET there is no matter what language you use to develop your application, as the code is compiled in IL (Intermediate Languge). IL is a stepping stone for every managed application. (A managed application is any application that’s written for .NET and executes inside the managed environment of the CLR.) In a sense, <u>IL is the language of .NET, and it’s the only language that the CLR recognizes

 Fact 4: ASP.NET Is Hosted by the Common Language Runtime


Automatic memory management and garbage collection
:
Every time your application instantiates an object, the CLR allocates space on the managed heap for that object. However, you never need to clear this memory manually. As soon as your reference to an object goes out of scope (or your application ends), the object becomes available for garbage collection. The garbage collector runs periodically inside the CLR, automatically reclaiming unused memory for inaccessible objects. This model saves you from the low-level complexities of C++ memory handling and from the quirkiness of COM reference counting.
Type safety:
When you compile an application, .NET adds information to your assembly that indicates details such as the available classes, their members, their data types, and so on. As a result, your compiled code assemblies are completely self-sufficient. Other people can use them without requiring any other support files, and the compiler can verify that every call is valid at runtime. This extra layer of safety completely obliterates low-level errors such as the infamous buffer overflow.

Extensible metadata:
The information about classes and members is only one of the types of metadata that .NET stores in a compiled assembly. Metadata describes your code and allows you to provide additional information to the runtime or other services. For example, this metadata might tell a debugger how to trace your code, or it might tell Visual Studio how to display a custom control at design time. You could also use metadata to enable other runtime services (such as web methods or COM+ services).

Structured error handling:
If you’ve ever written any moderately useful Visual Basic or VBScript code, you’ll most likely be familiar with the limited resources these languages offer for error handling. With structured exception handling, you can organize your error-handling code logically and concisely. You can create separate blocks to deal with different types of errors. You can also nest exception handlers multiple layers deep.

Multithreading:
The CLR provides a pool of threads that various classes can use. For example, you can call methods, read files, or communicate with web services asynchronously, without


Fact 5: ASP.NET Is Object-Oriented


Asp provides a relatively feeble object model, On the other hand Asp.net is truly object oriented.


Not only does your code have full access to all objects in the .NET Framework, but you can also exploit all the conventions of an OOP (object-oriented programming) environment. For example, you can create reusable classes, standardize code with interfaces, extend existing classes with inheritance, and bundle useful functionality in a distributable, compiled component.


Fact 6: ASP.NET Is Multi-device and Multi-browser

One of the greatest challenges web developers face is the wide variety of browsers they need to support. Different browsers, versions, and configurations differ in their support of HTML. Web developers need to choose whether they should render their content according to HTML 3.2, HTML 4.0, or something else entirely.


ASP.NET addresses this problem in a remarkably intelligent way.
Although you can retrieve information about the client browser and its capabilities in an .
Asp.Net page.
For example:
ASP.NET’s validation controls, which use JavaScript and DHTML (Dynamic HTML) to enhance their behavior if the client supports it. This allows the validation controls to show dynamic error messages without the user needing to send the page back to the server for more processing.


Fact 7: ASP.NET Is Easy to Deploy and Configure

ASP.NET simplifies deployment process as :- Every installation of the .NET Framework provides the same core classes. As a result, deploying an ASP.NET application is relatively simple. For no-frills deployment, you simply need to copy all the files to a virtual directory on a production server (using an FTP program or even a command-line command like XCOPY). As long as the host machine has the .NET Framework, there are no time consuming registration steps.

Thursday 4 April 2013

c# .net interview question answers

c# .net interview question answers
What is C#?

C# is an object oriented, type safe and managed language that is compiled by .Net framework to generate Microsoft Intermediate Language.  
  • C# is a new object-oriented language from Microsoft that is currently used for application development on the .NET platform.
  • It exhibits features found in languages such as C++, Java, Smalltalk, and Perl, among others.
  • C# has been submitted to the standards body.

What is the difference between abstract classes and interface?

Abstract class can have concrete methods while interfaces have no methods implemented.
Interfaces do not come in inheriting chain, while abstract classes come inheritance.

 What are the types of comment in C# with examples?
Single line
Eg:
   //This is a Single line comment
ii. Multiple line (/* */)
Eg: /* my name is chitranjan*/

What is the difference between public, static and void?
All these are access modifiers in C#.
Public:- Public declared variables or methods are accessible anywhere in the application.
Static:-  Static declared variables or methods are globally accessible without creating an instance of the class. The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created.
Void:- Void is a type modifier that states that the method or variable does not return any value.

What are the namespaces used in C#.NET?
    Namespace is a logical grouping of class.
  • using System;
  • using System.Collections.Generic;
  • using System.Windows.Forms;

What is an object?
An object is an instance of a class through which we access the methods of that class. “New” keyword is used to create an object. A class that creates an object in memory will contain the information about the methods, variables and behavior of that class.

What are the characteristics of C#?
    There are several characteristics of C# are :
  • Simple
  • Type safe
  • Flexible
  • Object oriented
  • Compatible
  • Consistent
  • Interoperable
  • Modern
What are the basic concepts of object oriented programming?
    It is necessary to understand some of the concepts used extensively in object oriented programming.These include
  • Objects
  • Classes
  • Data abstraction and encapsulation
  • Inheritance
  • Polymorphism
  • Dynamic Binding
  • Message passing.

What is an object? 
An object is an instance of a class through which we access the methods of that class. “New” keyword is used to create an object. A class that creates an object in memory will contain the information about the methods, variables and behavior of that class.

What is the difference between Object and Instance?
An instance of a user-defined type is called an object. We can instantiate many objects from one class.
An object is an instance of a class.

Define Constructors?  
A constructor is a member function in a class that has the same name as its class. The constructor is automatically invoked whenever an object class is created. It constructs the values of data members while initializing the class.
 

Wednesday 3 April 2013

How to Prepare Yourself for the Interview

How to Prepare Yourself for the Interview

How to Prepare Yourself for the Interview


I would like to provide you some of the valuable tips that have been researched and may work wonder for you.
Following are the things you must be prepared about:
1)    Things to be prepared before interview
  • Firstly analyze and re-read the job requirement detail and description and specification as well as nature of job. Match up the skills and knowledge you possess and the position you are interviewing for.
  • Searching and collecting vital information about the company would surely work in favor of you. The better you can present your insights about the company, the more you can get your employer impressed.
  • Expect some of the questions that would possibly be asked and accordingly prepare all the answers highlighting all your accomplishments, knowledge and skills through certain practical examples.
  • Finding out the name as well as title of the interviewer followed by time and place is vitally important for you. And practice again and again.

2)    During the interview
  • You must arrive 10-15 minutes earlier than normal schedule of interview.
  • Choose out matching clothes and dress up professionally.
  • On meeting the person interviewing you, make sure to maintain your eye contact, give warm smile and shake your hands firmly.
  • Never forget to carry your portfolio such as (copies of your résumé, transcripts, references, etc.)…
  • Show your positivity and enthusiasm because these are the qualities that are often sought by employers when it comes to determining suitability of any candidate for the post applied.
  • Maintain confidence and time while answering the questions asked.
  • Never forget to thank the employer after concluding the interview and firmly shake your hands and say good bye while leaving.

jquery form validation in asp.net

jquery form validation in asp.net

Introduction:

Validation is an important requirement in every enterprise application and every platform has its own implementation to this regards. In this article, I will illustrate how to implement client-side validation in ASP.NET using jQuery.

Description:


Now let's open the Visual Studio.NET and create a Web project for the example. Then add a new Web form for the user to enter some data below


Download the .js file and add you project in Scripts folder
Download Link is :Js Files
OR
Direct include the file like this
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.5.5/jquery.validate.min.js"></script>


Jquery code for form validation as shown below




<head runat="server">
  <title></title>
  <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="Scripts/JScript.js"></script>
  <script type="text/javascript" src="Scripts/JScript2.js"></script>
  <script type="text/javascript">
    $(document).ready(function () {
      // Initialize validation on the entire ASP.NET form
      $("#form1").validate({
     
        onsubmit: false
      });

      $("#Order").click(function (evt) {
   
        var isValid = $("#form1").valid();

     
        if (!isValid)
          evt.preventDefault();
      });
    });
  </script>
</head>

.aspx from code as shown below


<form id="form1" runat="server">
    &nbsp;

  <fieldset id="BillingInfo">
    <legend>New User Registration</legend>

    <label for="FirstName">First Name:</label>
    <asp:TextBox runat="server" ID="FirstName" CssClass="required" />
 
    <label for="LastName">Last Name:</label>
    <asp:TextBox runat="server" ID="LastName" CssClass="required" />
 
    <label for="Address">Address:</label>
    <asp:TextBox runat="server" ID="Address" CssClass="required" />
 
    <label for="City">City:</label>
    <asp:TextBox runat="server" ID="City" CssClass="required" />
 
    <label for="State">State:</label>
    <asp:TextBox runat="server" ID="State" CssClass="required" />
 
    <label for="Zip">Zip:</label>
    <asp:TextBox runat="server" ID="Zip" CssClass="required digits" />
 
    <asp:Button runat="server" ID="Order" Text="Submit " />
  </fieldset>
</form>

Full Image of Aspx Page Jquery and html code as show below



Output At the run time as shown below :- Click on Button then  get the jquery validation error corresponding to text box

2 : -Jquery Form Validation With Asp.Net With Source Code
In this example i will  explain how i can validated to email and text box using  jquery

Full Example as Show Below only Copy and Past this Code in our Page


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Jquery from validation</title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<style type="text/css">
* { font-family: Verdana; font-size: 96%; }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
</style>
 <script>
      $(document).ready(function () {
          $("#commentForm").validate();
      });
  </script>

</head>
<body>
    <form  class="cmxform" id="commentForm" method="get" action="" runat="server">
    <fieldset>
   <legend>A simple comment form with submit validation and default messages</legend>
   <p>
     <label for="cname">Name</label>
     <em>*</em><input id="cname" name="name" size="25" class="required" minlength="2" />
   </p>
   <p>
     <label for="cemail">E-Mail</label>
     <em>*</em><input id="cemail" name="email" size="25"  class="required email" />
   </p>
   <p>
     <label for="curl">URL</label>
     <em>  </em><input id="curl" name="url" size="25"  class="url" value="" />
   </p>
   <p>
     <label for="ccomment">Your comment</label>
     <em>*</em><textarea id="ccomment" name="comment" cols="22"  class="required"></textarea>
   </p>
   <p>
     <input class="submit" type="submit" value="Submit"/>
   </p>
 </fieldset>
    </form>
</body>
</html>

Screen Short As Shown Below

 

Download sample code attached



Tuesday 2 April 2013

how to count number of button clicks in asp.net

how to count number of button clicks in asp.net ?
Introduction:
Here, we will see how to check number of click on button click by the user.When user click on the button automatically increment by one.
Description:
In this article how i can count the user click on button .its a static counter when user refresh the page the counter start from zero. in my previous article i have explained how i can count the total click by the user on button click and display the result in text box.

Html file code as  shown below

Its a simple javascripts code for generate the number on button click by the user

<script type="text/javascript">
    var index = 0;

    function increment(var1) {
        index++;
        if (var1 == 1)
        { document.getElementById('button1').value = index; }
        else
        { document.getElementById('button2').value = index; }

    }
</script>
calling the javascript funtion on button click and display the total click by the user

<form id="form" runat="server">
    <div>
    <input type="button" id="button1" onclick="increment(0)" value="increment"/>
    <input type="button" id="button2" onclick="increment(1)" value="increment again"/>
    </div>
    </form>

Image for show all the complete code as show below
Example show below



Download sample code attached

Monday 1 April 2013

Count the number of times a submit button has been clicked

Count the number of times a submit button has been clicked

Count the number of times a submit button has been clicked

Introduction
  How i can find the user click on submit button in multipal time

GUI Html Code As Shown Below

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="counter.aspx.cs" Inherits="counter" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
  
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="counter" />
&nbsp; Show Total Click of Particular User
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  
    </div>
    </form>
</body>
</html>

From Image as shown below
On Button Click Couter Code Behind 
static int count = 0; 
protected void Button1_Click(object sender, EventArgs e)
    {
        count++;
        int totalcount = count;
        TextBox1.Text = totalcount.ToString();
    }

Output as shown below

Download sample code attached







Simple difference between String and StringBuilder asp.net

Simple difference between String and StringBuilder asp.net

Simple difference between String and StringBuilder asp.net

The main difference beween string and stringbuilder is that when we are copying two string in the case of string concatination is done means that one string is attached to another string and attaced string is deleted, and one new memory allocation is done.it takes lot of time and this is time taking process.


but in case of stringbuilder copying two stings means string1 is appended to string2 or vice versa.no memory allocation and deletion of string.So it is very efficient process and it takes less time.

Difference Between String and String
String


1.Its a class used to handle strings.
2.Here concatenation is used to combine two strings.
3.String object is used to concatenate two strings.
4.The first string is combined to the other string by creating a new copy in the memory as a string object, and then the old
string is deleted
5.That is why  "Strings are immutable".
6. Slower

String Builder
1.This is also the class used to handle strings.
2.Here Append method is used.
3.Here, Stringbuilder object is used.
4.Insertion is done on the existing string.
5.Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.
6. Faster

class
Program{static void Main(string[] args){
//for example:

string str = "hello"; //Creates a new object when we concatenate any other words along with str variable it does not actually modify the str variable, instead it creates a whole new string.
str = str + " to all";Console.WriteLine(str);StringBuilder s = new StringBuilder("Hi");s.Append(" To All");Console.WriteLine(s);Console.Read();}
}

query string in asp.net

query string in asp.net

Introduction:

The QueryString collection is used to retrieve the variable values in the HTTP query string.
The HTTP query string is specified by the values following the question mark (?),
 like this:
http://localhost:2525/QueryString/getquerystring.aspx?name=rahul&password=123.
 Query strings are included in bookmarks and in URLs that you pass in an e-mail. They are the only way to save a page state when copying and pasting a URL.

Description:


Now I have one page which contains one textbox and button control I need to send textbox value to another page when we click on button control for that we need to write the code like this
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("getquerystring.aspx?name="+this.txt_nm.Text);
}
Or
In case if we need to send multiple parameters to another page we need to write code like this
protected void btnSend_Click(object sender, EventArgs e)
{
Response.Redirect("getquerystring.aspx?name="+this.txt_nm.Text+"&password="+this.txt_pass.Text);
}
Now we need to get these values in another page (here I mentioned Default2.aspx) by using QueryString Parameter values with variable names or index values that would be like this
protected void Page_Load(object sender, EventArgs e)
{

string name = Request.QueryString["name"];
string password = Request.QueryString["password"];

}

first create new website and open Default.aspx page and write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>QueryString Example in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div><b>QueryString Example</b></div><br />
<div>
<table>
<tr>
<td><b>Enter the Name:</b></td>
<td><asp:TextBox ID="txt_nm" runat="server"/></td>
</tr>
<tr>
<td><b>Enter the Password</b></td>
<td><asp:TextBox ID="txt_pass" runat="server"/></td>
</tr>
<tr>
<td></td>
<td><asp:Button ID="Button1" runat="server" onclick="Button1_Click"/></td>
</tr>
</table>
</div>
</form>
</body>
</html>
After that write the following code in code behind
protected void btnSend_Click(object sender, EventArgs e)
{
Response.Redirect("getquerystring.aspx?name="+txt_nm.Text+"&pasword="+txt_pass.Text);
}
Now Right click on your website and Add New item and add new page (getquerystring.aspx) open that getquerystring.aspx page and write the following code
On  code behind
protected void Page_Load(object sender, EventArgs e)
{

 string name = Request.QueryString["name"];
 string password = Request.QueryString["password"];
Response.Write("name=" + name + "\t" + "password=" + pasword);
}

Example



Download sample code attached



 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result