P. 1


|Views: 4|Likes:
Published by Christopher Francis

More info:

Published by: Christopher Francis on Feb 15, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





What is a Constructor?

A constructor is a member function that has the same name as the class name and is invoked automatically when the class is instantiated. A constructor is used to provide initialization code that gets executed every time the class is instantiated. Points to be noted on constructors: • Constructors cannot be "virtual". They cannot be inherited. • Constructors are called in the order of inheritance. • If we don't write any constructor for a class, C# provides an implicit default constructor, i.e., a constructor with no argument. • Constructors cannot return any value. • Constructors can be overloaded. The syntax for a constructor is as follows: [modifier] name (parameters) { // constructor body} A constructor can have the following modifiers. public, protected, internal, private, extern Two types: Static or class constructors & Non–static or instance constructors Static Constructors • A static constructor or class constructor gets called when the class is instantiated or a static member of the class is used for the first time. • A Static constructor cannot be overloaded. • It should be without parameters and can only access static members. • It cannot have any access modifiers.

The static constructor for a class executes only once in an application domain. Static constructors cannot be chained with other static or non-static constructors.

Static Constructor Executes Before an Instance Constructor. In the program that follows, the static constructor is invoked once the static variable of the class is referenced. using System; class Test { private static int i; static Test() { Console.WriteLine ("Static Constructor."); } public static int Assign { set { i = value; } get { return i; } } } class Sample { public static void Main() { Test.Assign = 2; }

} Listing 2: Static Constructor Executes Before an Instance Constructor using System; class TestClass { static TestClass () { System.Console.Write("Static "); } public TestClass () { System.Console.Write("Instance "); } } class Test { static void Main() { new TestClass (); Console.ReadLine (); } } The output of the above program is 'Static Instance'. A static constructor can only access static members of a class. The reason is that at the time when a static constructor is loaded in the memory, the instance members of a class are not available. In the following program, the assignment to the non–static integer variable p inside the static constructor is an error. Listing 3: Static Constructor Can Access Only Static Members class Test { int p; static Test() { p = 9; } public static void Main(string []args) { Test testObject = new Test(); /*Error: An object reference is required for the non-static field, method, or property 'Test.p'*/ } } Non-Static or Instance Constructors Non-static constructors are also called instance constructors, type constructors, or type initializers, and are used to create and initialize instances of the class they belong to. We can have multiple non-static constructors but only one static constructor for a class. A non-static constructor with no parameters is called the default constructor. If we do not write any constructor for a class, the compiler automatically supplies one. This is the implicit default constructor. This property of C# to supply an implicit default constructor is revoked once we write any constructor for a class. Non-static constructors can be public, private, protected, external, or internal. A public constructor is one that is called when the class is instantiated. A private constructor is one that prevents the creation of the object of the class. It is commonly used in classes that contain only static members. A class containing an internal constructor cannot be instantiated outside of the assembly. An internal constructor can be used to limit concrete implementations of the abstract

class to the assembly defining the class. A protected constructor allows the base class to do its own initialization when subtypes are created. When constructor declaration includes an extern modifier, the constructor is said to be an external constructor. An external constructor declaration provides no actual implementation and hence does not contain any definition. It is to be noted that a public constructor can access a private constructor of the same class through constructor chaining. Listing 4: Public Constructor Can Access Private Constructor of the Same Class using System; class Test { public Test(): this(10) { Console.WriteLine("Default Constructor"); } private Test(int intValue) { Console.WriteLine("Parameterized Constructor"); } public static void Main(string []args) { Test testObject = new Test(); Console.ReadLine (); } } The output is as follows: Parameterized Constructor Default Constructor A protected constructor can only be invoked from the subclasses of the class in which it is defined. This is illustrated in the example that follows. Listing 5 using system; class B { protected B (string s) {} } class D : B { public D () : base ("Called from D class") {} } class E { public static void Main(string []args) { B x = new B ("Called from E class"); /*Error. The constructor test.B.B(string s) is inaccessible due to its protection level*/ } } Constructor Overloading A constructor can take zero or more arguments as parameters. A constructor with zero arguments is known as the default constructor. We can have multiple constructors in a class with different sets of signatures. Such constructors are known as “overloaded constructors”. The overloaded constructors of a class must differ in their number of arguments, type of arguments, and/or order of arguments. This gives the user the ability to initialize the object in multiple ways.

} } Constructor Chaining Constructor chaining refers to the ability of a class to call one constructor from another constructor. Listing 6: Overloaded Constructors using system. int secondValue) { // This is the constructor with two parameters. a derived class constructor can call a base class constructor. public class Test { public Test() { //Default constructor } public Test(int sampleValue) { // This is the constructor with one parameter. followed by the two argument constructors. we use base (parameters) or : this (parameters) just before the actual code for the constructor. } . } public Base(int x) { Console. depending on whether we want to call a constructor in the base class or in the current class. provided both are non-static. The first is the default constructor. class Base { public Base() { Console. In order to call one constructor from another. Note that the constructors differ in their signature.The class in the program shown below contains three constructors. Listing 8: Invoking a Base Constructor from the Derived Class using System.WriteLine("Base Constructor Version 1"). public class Test { public Test(): this(10) { // This is the default constructor } public Test(int firstValue) { // This is the constructor with one parameter. } public Test(int firstValue. } } Constructors and Inheritance A constructor of a base class is not inherited to its derived class. Listing 7: Constructor Chaining using system.WriteLine("Base Constructor Version 2"). However.

} } Constructors are executed in the order of inheritance as shown in the example below. class Base { public Base() { Console. //Displays 'Base constructor' followed by 'Derived constructor'. { public static void Main() { . } } It is not possible to inherit a class that has only a private constructor. } } class MyClient { public static void Main() { Derived dObject = new Derived().WriteLine("Base constructor"). } } class Derived : Base { public Derived() { Console. //Displays 'Base Constructor Version 2' followed by 'Derived Constructor'.WriteLine("Derived Constructor").} class Derived : Base { public Derived():base(10) { Console.WriteLine("Derived constructor"). Listing 10: Private Constructors Prevent Inheritance using system. Listing 9: Order of Execution of Constructors in Inheritance using System. } } class Test { public static void Main() { Derived dObject = new Derived(). class Base { Base( ) { } } class Derived : Base // Syntax Error.

WriteLine("Calling the method Math. and then used to call this method. } } Conclusion The best practice is to always explicitly specify the constructor.Divide).Divide() through the dDelegate object"). int second) { return first * second. Console.Add() through the aDelegate object"). int y).ReadLine().Derived dObject = new Derived ().WriteLine("Calling the method Math. DelegateToMethod dDelegate = new DelegateToMethod(Math.WriteLine(dDelegate(5. You use the delegate keyword as in the following statement. you create a new delegate type in a different way than you create any other class. int y).5)).5)). public class Math { public static int Add(int first. public delegate int DelegateToMethod(int x.Multiply() through the mDelegate object"). The First Delegate Example using System. int second) { return first / second.WriteLine("Calling the method Math. namespace Delegates { public delegate int DelegateToMethod(int x.WriteLine(mDelegate(5. Console. } } public class DelegateApp { public static void Main() { DelegateToMethod aDelegate = new DelegateToMethod(Math. Console. Console. Console. } public static int Multiply(int first.WriteLine(aDelegate(5. } public static int Divide(int first.Add). Console. C# Delegates Explained A delegate is an object that refers to a static method or an instance method A delegate is an object that is created to refer to a static method or an instance method. even if it is a public default constructor.Multiply). } } } . To start off.5)). Proper design of constructors goes a long way in solving the challenges faced in class designs. Console. DelegateToMethod mDelegate = new DelegateToMethod(Math. int second) { return first + second.

WriteLine("The method Add() returns {0}". first * second). int second) { Console. multiDelegate += new Math.Multiply).DelegateToMethod multiDelegate = null.WriteLine("The method Divide() returns {0}". using System. first + second). multiDelegate(10.Divide). Invoking the delegate invokes each delegate (which in turn calls its encapsulated method) in the same order that it has been added to the linked list. multiDelegate += new Math. int y).Add). public void Add(int first. } public void Divide(int first. int second) { Console.WriteLine("The method Multiply() returns {0}". } } public class DelegateApp { public static void Main() { Math math = new Math(). Console. int second) { Console.10).Multicast Delegates A multicast delegate is an object that maintains a linked list of delegates.DelegateToMethod(math. first / second). Math.DelegateToMethod(math.DelegateToMethod(math.ReadLine(). } } } . } public void Multiply(int first. namespace Delegates { public class Math { // note that the delegate now is a nested type of the Math class public delegate void DelegateToMethod(int x.DelegateToMethod and assigned a null value to this object. multiDelegate = new Math. In our example we have created an object (a delegate) called multiDelegate of type Math.

Operator Overloading In C# The mechanism of giving a special meaning to a standard C# operator with respect to a user defined data type such as classes or structures is known as operator overloading. new. They can take only value arguments. Remember that it is not possible to overload all operators in C#. >> +. Operators Overloadability +.operator inside the class Complex // Unary operator overloading using System. The following program overloads the unary . %. but the return type must be the type of 'Type' for ++ and o remember that the true and false operators can be overloaded only as pairs. These special function or method must be public and static. /=. The general form of an operator function is as follows. there is only one argument and for overloading a binary operator there are two arguments. . int j) { x = i. public static return_type operator op (argument list) Where the op is the operator to be overloaded and operator is the required keyword. public Complex() { } public Complex(int i. ~. !=.). >. &. as. *. *=. true. <. But in C#. public static return_type operator op (Type t) { // Statements } Where Type must be a class or struct. ?:. } . For overloading the unary operators. The following table shows the operators and their overloadability in C#. these operators are automatically overloaded when the respective binary operator is overloaded. They can't be overloaded They can't be overloaded These compound assignment operators can be overloaded. y = j. is. Overloading Unary Operators The general form of operator function for unary operators is as follows. Remember that at least one of the arguments must be a user-defined type such as class or struct type. The compilation error occurs if a class declares one of these operators without declaring the other. |. . sizeof These operators can't be overloaded In C#. <<. --. ++. !. ! and dot (. All C# unary operators can be overloaded. /. =. class Complex { private int x. || () (Conversion operator) +=. a special function called operator function is used for overloading purpose. -. The return type can be any type except void for unary operators like +. <= . >= &&. %= All C# binary operators can be overloaded. private int y. but only as pairs. ~. All relational operators can be overloaded. -=. -. false ==. ->. The ref and out parameters are not allowed as arguments to operator functions.

class Complex { private int x.y.WriteLine(\"{0} {1}\". } public static Complex operator -(Complex c) { Complex temp = new Complex(). temp. public static return_type operator op (Type1 t1. // diapls -10 & -20 } } Overloading Binary Operators An overloaded binary operator must take two arguments.x = -c. } public void ShowXY() { Console.ShowXY().x.y). return temp.x. private int y. public Complex() { } public Complex(int i.ShowXY(). Type2 t2) { //Statements } A concrete example is given below // binary operator overloading using System.20). // displays 0 & 0 c2 = -c1. // displays 10 & 20 Complex c2 = new Complex(). c2.public void ShowXY() { Console. c2. } } class MyClient { public static void Main() { Complex c1 = new Complex(10. The general form of a overloaded binary operator is as follows.WriteLine(\"{0} {1}\". But overloaded binary operators can return any value except the type void. c1. int j) { x = i.y = -c.x. . at least one of them must be of the type class or struct.y). in which the operation is defined. y = j.ShowXY(). temp.

>.Operator overload methods can't return void.Text). long factorial = 1. ! =. c2. temp. // calculate factorial while ( number > 0 && number <= 20) { factorial *= number.y+c2. // dislplays 30 & 50 } } The binary operators such as = =. c3. corresponding assignment operators also get overloaded automatically.y = c1.y. precedence or associativity of an operator.ToInt64 (txtNumber. // displays 20 & 30 Complex c3 = new Complex().The operator overload methods can be overloaded just like any other methods in C#. Write code for Factorial? private void btnCalculae_Click(object sender.x = c1. Summary 1. System.x.ShowXY().ToString("n20"). For example if we overload + operator. } // end while loop .} public static Complex operator +(Complex c1. a + operator is always a binary operator having a predefined precedence and an associativity of left to right. number++. The overloaded methods should differ in their type of arguments and/or number of arguments and/or order of arguments.EventArgs e) { long number = Convert.x+c2. > = can be overloaded only as pairs. } } class MyClient { public static void Main() { Complex c1 = new Complex(10.Text = factorial.ShowXY().User defined operator implementations are given preference over predefined implementations. <. 3. // displays 10 & 20 Complex c2 = new Complex(20. lblFactorial. For example. Remember that when a binary arithmetic operator is overloaded. < =. it implicitly overloads the + = operator also. 2. c1.30). Remember that in this case also the return type is not considered as part of the method signature.Complex c2) { Complex temp = new Complex(). c3 = c1 + c2.ShowXY().The user defined operator declarations can't modify the syntax. return temp. temp.20). 4.

System.1) == myString.Length . } txt2.Substring(Second. int Second. Second --. while (First < Second) { if(myString.Text = "".Substring(First. } private void btnExit_Click(object sender.EventArgs e) { this.Focus().1)) { First ++. foreach char c in str { fact=convert. } Or private bool CheckPalindrome(string myString) { string strrevs="".txtNumber. First = 0. else return false.Close().text=fact.1.EventArgs e) { string str =txt1. txtNumber. } Write code for palindrome? private bool CheckPalindrome(string myString) { int First. } } } private void btnCalculae_Click(object sender. int fact=1. } if (strrevs==myString) return true. Second = myString.text.toint32(c)*fact. } . foreach char c in myString { strrevs= c + strrevs. } }return true. System. }else{ return false.

else ErrMessage = "No Errors". Many web pages take parameters from web user. then you do not need the maintain it's view state. set the EnableViewState property of the control to false. To disable it. Response.net . If we disable Enableviewstate property then after postback that control will lose the previous state. since the state of a control is passed to and from the server in a hidden form field. ViewState is enabled for all server controls by default. If we Enable Enableviewstate property then the state of that particular control will remains even after postback.How to find last error which occurred? Answer #1 Exception LastError. web page that user name and password and make SQL query to the database to check if a user has valid name and password. if you are binding a control every round trip. String ErrMessage.GetLastError(). For example.net? How do u disable them? Answer #1 Validator means checking inputed data in any field like textBox or dropdownbox any other which we want to validate . This feature is not free however.Message. Username: ' or 1=1 --Password: [Empty] This would execute the following query against the users table: select count(*) from users where userName='' or 1=1 --' and userPass='' What are validator? Name the Validation controls in asp. Asp. and make SQL query to the database.Enable ViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code.Write("Last Error = " + ErrMessage). What is SQL injection? Answer #1 An SQL injection attack "injects" or manipulates SQL code by adding unexpected SQL to a query. LastError = Server. Take for instance when a user login. if (LastError != null) ErrMessage = LastError. You should when it is to data on control to be aware of when ViewState is helping you and not.

CompareValidator control 4.appendcookie(cook).> < /authorization > < !-< !-- Security types in ASP/ASP.config file. roles map to names used to identify user groups. cookie prepared or modified by the server side script will be appended to the response and will be sent to the client. . RequireFieldvalidator control 3.Micsoft Authentication 3. Ranage validator control 2. dim cook as httpcookie cook=new httpcookie("items") cook. add the <ROLES>element to the authorization list in your Web application's Web. 1. Users.g. ValidationSummary control if we mention in our page but want to disable just use the property of validator control causevalidation=false. including Administrators.Form Authentication Cookie is like a temporary file which contains a name and a value pair and resides in the client. Windows defines several built-in groups.e.> < deny users="*" / > Deny anyone else. -. -.Windows Authentication (i)Anoymous (ii)Basic (iii)Digest (iv)Windows integated 2.Net 1.value=textbox1. CustomValidator control 6. RegularExpressionValidator control 5. and Guests. Following are type of validator control in asp.NET? Different Authentication modes? Answer #1 There r 3 types of security in .To allow or deny access to certain groups of users. What is role-based security? Answer #1 Role Based Security lets you identify groups of users to allow or deny based on their role in the organization. <AUTHORIZATION>< authorization > < allow roles="Domain Name\Administrators" / > Allow Administrators in domain.text response.In Windows NT and Windows XP.net.at client side using sever tag.

1 which (correctly I say) posted back the READONLY value. u want to dispaly on the website..0 Sapna Re: How do you create a permanent cookie? Answer #2 You can set the permanent cookied by setting the expiry date to the MaxDate <% Response. and so on. enabling developers and Web designers to work together.MaxValue %> how can u display multi language (i.exe files are executed in its own address space whereas . 3) A new model for compiling and distributing applications. what is the differance between .NET 2...DLL & .dll files requires address space . example we use utiltity or function written in vb can be used in cs code also. 2) Superior separation of design and content.0 the value gets lost..Cookies("username") = "you" Response. MultiView.spanish. This even though the value is actually returned in the POST buffer.) web site? Answer #2 Create resource files for each language. 5) Master pages Bug in ASP.EXE The main difference is that .. 4) Customization with Web Parts. Wizard and FileUpload.Cookies("username"). This behavior is also different than 1.string.0 include: 1) A wide array of new controls. such as GridView control. Benefits of ASP.0:If you have a control on a page that is marked Read-Only and EnableViewState is set to false on the Page. set the string(u want to convert) to the resource manager.(add+new item+resource file) now create instance for resourcemanager class and set its path. the ReadOnly value will no longer post back in ASP.innerhtml=resourcemanager1.Expires = Date.e english.NET 2.0 we can use both vb and cs code in same project.NET 2. In 2. now panel1.

0 Answer #1 ASP. which targets clr is called as managed code. The control which posts the page and all the control values it contains has PostbackURL property.NET pages typically post back to themselves in order to process events. alert(brw. And the receiving page uses PreviousPage property and the PreviousPageType page directive to access the posting page values 0 Swapna Re: How many types of session in asp.appname). .net InProc OutProc SqlServer what is the differance between native code & managed code? Answer # 2 native code is cpu dependent and managed code target to clr The code. we can identify the browser name using javascript About the Usage of htmlencode and urlencode ? Answer #1 Use the Htmlencode method to encode input parameters when generating display.net2.appversion).0 Answer #2 three types of session states in asp. alert(brw.to run How to find the client browser type ? Answer #1 Request.UserAgent 0 Nirakar Re: How to find the client browser type ? Answer #2 var brw = new navigator(). Use the urlencode method to encode the url's input parameters recieved as How many types of session in asp.net2. Cross Page posting enables us to submit a form and have this form and all its control values posted to another page.

The recommendation is to leave cookies on and let the server automatically fall back to the cookieless operation only when required by a specific client connection. Furthermore. the server must work harder to track the session state. clients are not required to accept cookies.managed code that does not have any providers . However. you can turn off the use of cookies for session tracking altogether in the Web Application Server Control Panel. What is the difference between session state and session variables ? Answer #1 Session state is used to store session specific information for a website. You can cipher/decipher this code. you can use native code.ToString().:string myName=Session["Name"]. If cookies is disabled in client browser will session work ? Answer #1 No session will not work. you can also store other information in the session in order to make it available to subsequent requests without explicitly passing it to that request. .the session ID and a timestamp. However when cookies are turned off or cookies are not enabled on a specific client computer. 0 Pramod Re: If cookies is disabled in client browser will session work ? Answer #2 Sessions are normally tracked with cookies. which has a performance impact. or it may be self-modifying code for more safety. If you want to prevent your program from being cracked by hackers. 2. e.In first page set session variable. some information is automatically stored in it .g.if we set cookies session to true then it will work. e. as an application developer.it is very fast than unmanaged code. How do you pass session values from one page to another ? Answer #1 1. Session ["Name"] = "Pravesh". When a session is created by the server.g. Here "Name" is name of session variable and "Pravesh" is the value of session variable "Name". In next page get the sesion variable.

IsCOLUMNNAMENull response. and a convention for representing RPCs (Remote Procedure Calls) and responses. Searches can be performed by company name. It is based on XML and consists of three parts: a SOAP envelope (describing what's in the message and how to process it). Companies can publish WSDLs for services they provide and others can access those services using the information in the WSDL. This allows companies providing or needing web services to discover each other. What is JIT. Econo-JIT compiles only those methods that are called at runtime. How to check null values in dataset ? Answer #1 Dataset. Links to WSDLs are usually offered in a company?s profile in the UDDI registry. Membership is free and members can enter details about themselves and the services they provide.session variable store infomation between http request for a particular user.TableName[RowNumber]. 0 03/05/2007 Re: What is JIT. WSDL (Web Services Description Language) defines the XML grammar for describing services as collections of communication endpoints capable of exchanging messages. Discovery.IsQueueNumberNull() What is SOAP. . what are types of JITS and their purpose ? Answer #2 There are three types of JIT copilers. what are types of JITS and their purpose ? Answer #1 JIT is Just in Time compiler which compiles the MSIL into NAtive code. UDDI and WSDL ? Answer #1 SOAP (Simple Object Access Protocol) is a simple protocol for exchange of information. Pre-JIT compiles complete source code into native code in a single compilation cycle. and Integration) is a specification designed to allow businesses of all sizes to benefit in the new digital economy. specific service. This is done at the time of deployment of the application. There is a UDDI registry. define how they interact over the Internet and share such information in a truly global and standardized fashion. or types of service. a set of encoding rules. UDDI (Universal Description. there are 2 types of JITS. Econo-JIT.PayAnyonePaymentDetails[0]. Pre-JIT. which is open to everybody.

the code which is in environment of clr is called managed code. Normal-JIT. the compiled code from cache is used for execution. The CLS includes a subset of the Common Type System (CTS).so that that has some responsibilites that is to tack care of the execution of code other responsibilites garbage collection-in that it remove the object which are not refered for long time.net there is CLR.using Idisposable interface with dispose method Jit compiler also convert IT to native code In that include exception handling. the CTS specifies no particular syntax or keywords. Normal-JIT compiles only those methods that are called at runtime. and then they are stored in cache.etc Cls common language spefication thsi is guideline that to communicate smoothly with other CTS common type system this is used to communicate with other language.every language has runtime in case of . CLS and CLR ? Answer #1 Common Type System CTS :A fundamental part of the . When the same methods are called again. CLS and CLR ? Answer #2 CLR this is common language runtime. These methods are compiled the first time they are called.However. The CLR is a multi-language execution environment 0 Mouli Re: What is CTS. What is CTS. Common Language Specification (CLS):The Common Language Specification (CLS) describes a set of features that different languages have in common. but instead defines a common set of types that can be used with many different language syntaxes.int32 .NET Framework's Common Language Runtime (CLR). example in vb we have int and in c++ we have long so that in one case they are not compatiable with each other so that CTS palys important role with using System. these compiled methods are removed when they are not required.

It is a collection of event handlers that you can use to change and set settings in your site.cofig ? Answer #1 ? To set the UI culture and culture for all pages.config Regards sridhara krishna bodavula 0 Sridhara Krishna Re: Tell About Global. add a globalization section to the Web.config a application can have ? Answer #1 In an application you can create number of web.asax ? Answer #1 Global.asax ? Answer #2 it allows to execute application level events and set application level variables.It exists at the root folder of the project. and then set the uiculture and culture attributes.config ? Answer #1 generaly we store our connection string in web. It is inaccessible over the web but is used by the ASP.config file.The HTTPApplication object and any HTTPModule object that is specified in web. How do you retrieve information from web. Tell About Global.confg or machine. as shown in the following example: <%@ Page UICulture="es" Culture="es-MX" %> How many web. set the Culture and UICulture attributes of the @ Page directive.How do you set language in web. but by default only one in an application 0 Deepak Kumar Srivastava Re: How many web.asax is a file that resides in the root directory of your application. as shown in the following example: <globalization uiculture="es" culture="es-MX" /> ? To set the UI culture and culture for an individual page.config file under tag <appsetting> .but they are not in same directory. The events can come from one of two places .NET application if it is there.config file .config file per project.config a application can have ? Answer #2 You can have a single web.

.NET Web application.appsetting.Configuration.formatException Input string was not in a correct format."/> </appsetting> and for accessing the value in aspx page we writes string const= configurationsetting.. What are Http handler ? Answer #1 An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP. the request is processed by the page via the page handler. Both handler interfaces require you to implement the IsReusable property and the ProcessRequest method. Does the following statement executes successfully: Response.ConfigurationSettings.Write(?value of i = ? + i).. To create a custom HTTP handler..Write(?value of i = ? + i).And that key value u can retrive like string connectionString = System. The IsReusable property specifies whether the IHttpHandlerFactory object (the object that actually calls the appropriate handler) can place your handlers in a pool and reuse them to increase performance.ToString() Here conStringWeb is my key and i access its value.aspx file.AppSettings ["conStringWeb"]. or whether it must .aspx files. Answer #2 if you would have declared and assigned some value to the variable "i" then it will execute. When users request an . Answer #1 System. 0 Raj Re: Does the following statement executes successfully: Response. you create a class that implements the IHttpHandler interface to create a synchronous handler or the IHttpAsyncHandler to create an asynchronous handler. The most common handler is an ASP.connection_string 0 Ansu_kumar Re: How do you retrieve information from web.<add key=connection_string value="data source=.congig you can add key and its value.NET page handler that processes ..config ? Answer #2 In web.

calling and writing unmanaged code are different things. Types of configuration files and their differences ? Answer #1 app.Net application and how to secure applications. 3.Net Command prompt.config contains settings that apply to an entire computer. . Net. 1.Net web application project. If you find that. 2. So what is the order in which the Page life Cycles takes place? Answer #1 order of events are init page load control load page unload How to write unmanaged code and how to identify whether the code is managed / unmanaged ? Answer #1 you can only write unmanaged code in c# not in vb.create new instances every time the handler is needed.This file inherits setting from the machine. To identify whether the code is managed or not open the file in ildasm in VS. which can be used to check the headers.This is automatically created when you create an ASP.This is automatically installed when you install Visual Studio.net. it is managed assembly.config Machine. 1. In a page u have Web user controls .This is also called machine level configuration file.Net tool called dumpbin.net you can only call unmanaged code in vb.This file is at the highest level in the configuration hierarchy.config-> contains application specific settings web. Also you can use a . This file is located in the %runtime install path% \Config directory. 2. built-in remoting channels. Machine. where.config is a security in ASP. 3. or open the dll in notepad and check for "V e r s i o n". The ProcessRequest method is responsible for actually processing the individual HTTP requests. 4.config Web. Web. what. when and how to be authenticated.Only one machine.config does most of the work for the application the who.config contains configuration settings for machine-wide assembly binding.This is also called application level configuration file.config file exists on a server.

Define control Spacific attributes to used by ASP. View State is not updated with a callback (it's the same instance of the page just updated!!!). a callback does not refresh the currently viewed page (i.import a namespace in Page or user control explicit. Obviously from this. when a user selects a value of a the first.e.Defining class or vartual Path used to type master page property of page. When users request the content pages. @ Impliment : . You can think of it as a quick trip back to get some data etc.NET master pages allow you to create a consistent layout for the pages in your application.NET? Answer #2 @assembly : . a callback can enable you to only go fetch the required data.exe Process 3) SQL Server : session values are stored in SQL server Databases What are Master pages? How to define a Master page? Answer #1 ASP. does not redraw the page).Identifies a page as a master page and defines attributes used by the ASP. For example if there were two drop down boxes.master files @ Master Type:. How many Directives r in ASP. You can then create individual content pages that contain the content you want to display.Link assembly to current Page or user control directory .ascx page. @ Master :. doing some server side calculations and returning a new whole page to the client.Types of values mode can hold session state in web.exe process 2) StateServer : session values are stored in ASPNET_state.NET? Answer #2 The difference between a callback and postback is that.Net page parser and compiler included only in .NET page parser and compiler and can be included only in .config ? Answer #1 1) Inproc Mode : where the values are stored in ASPNET_WP.NET Framework interface declaratively @ import :. What is Difference between Callbacks and Postback in ASP. @control :.Indicates that a page or user control implements a specified . rather then posting the whole page. 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. . they merge with the master page to produce output that combines the layout of the master page with the content from the content page. as with a postback. the second dependant on the value of the first.

They have many things in common like DataSource Property . Datalist are ASP. @Reference . @Page. @Register WHAT ARE DEFFERENCE BETWEEN DATALIST AND DATAGRID Answer #1 A Datagrid. Datagrid has a inbuild support for Sort. RequiredFieldValidator--write code in javascript Answer #2 function validate() { if(document.value == null) alert("Please enter the name").url. But The HTML code generated for a Datagrid has an HTML TABLE <ROW> element created for the particular DataRow and its a Table form representation with Columns and Rows.description .Filter and paging the Data . When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem and this is same for the rest of the two controls also. document. In addition to these .net 2. return false. For a Datalist its an Array of Rows and based on the Template Selected and the RepeatColumn Property value We can specify how many DataSource records should appear per HTML <table> row. DataBind Method ItemDataBound and ItemCreated . @Privious Page Type.getElementById("NameId"). } in button OnClick() we hav to cal this function what are the sitemap providers in Asp.NET data Web controls.getElementById("NameId").@OutPut Cache.TreeView and Menu controls why security trimming attribute? Answer #1 It is used to hide links in site map what are the attributes of sitemapnode? Answer #1 Title.0? Answer #1 SiteMapPath.focus().which is not possible when using a DataList and for a Repeater Control we would require to write an explicit code to do paging.

This uses a SQL Server user store what are the new server controls added in Asp. This uses either an Active Directory or Active Directory Application Mode (ADAM) user store.0? Answer #1 Navigation Controls: Site MapPath TreeView Menu DataBindingControls SqlDataSource oledbDatasource ObjectDataSource DataCotrols: GridView DetailsView FormsView What are skins? Answer #1 skin file is used to set the design settings of our html controls as well as web server controls .NET version 2. It also provides a membership API that simplifies the task of validating user credentials when used with forms authentication. * SqlMembershipProvider.0? Answer #1 The ASP.net 2.0 membership feature provides secure credential storage for application users.. ASP.What is the use of Administration tool in Asp.net 2.skin files are used for web server controls How to remove themes from certain controls? Answer #1 Override the property EnableTheming by setting it to "False" for those controls diffrance between stored procedure & function in sql server? Answer #2 Difference between function and stored proc: ======================================================== Stored Procedure :supports deffered name resoultion Example while writing a stored procedure that uses table named tabl1 and tabl2 etc.NET 2. Membership providers abstract the underlying store used to maintain user credentials.but actually not exists in database is allowed only in during creation but runtime throws errorFunction wont support deffered name .css file is used for html server controls .0 includes the following providers: * ActiveDirectoryMembershipProvider.

delete) statements in a function. 10.select myFunction(field) from sometable. 11.. You can have DML(insert. 4.resolution. where as sp is not so 6. update. Stored procedure returns always integer value by default zero. Function do not return the images. procedures need not be. procedure can return multiple values(max. Function parameters are always IN. 8. Functions are used for computations where as procedures can be used for performing business logic 9. 5. will throw error.text whereas sp returns all. if u have a function that is updating a table. 1024) we can select the fields from function. no OUT is possible difference between caching objects in session objects? Answer #1 session object creates for each user indivisually but 1 cach object for one application. But function returns 1 value only. We can call the functions in sql statements (select max (sal) from emp). Stored Procedure retuns more than one value at a time while funtion returns only one value at a time. Functions MUST return a value. . 7.s you need not write a code for that just call in the web method you need for that time Differnce:-The ultimate difference between these two is .. But. 3. in the case of procdure we cannot select the fields.eg: suppose. Function and sp both can return the values. you cannot call such a function in a SQL query. you can't call that function in any sql query. 2. How Web Services help Us? What r the difference between Remoting and webservices Answer #1 HI!! Web services are those services delivered via web and assume that ur project comprising of timezone of u. where as function return type could be scalar or table or table values(SQL Server). Stored Procedure is pre compiled exuction plan where as functions are not.

if i click the button .if no the validation control is not fired. In remoting data is passed as streams whereas webservices communicates in XML Format If we add a textbox and give the required field validator..SOAP.con) dataset ds = new dataset. sqlDataAdapter da= new slqDataAdapter(str.CausesValidation = True Else If Me. If you select one city in list box the information related to that particular city should be displayed in Datagrid .Checked = True Then Me.if the radio button Yes is checked the validation control is fired .RadioButton1.."City").Checked = True Then Button1. Answer #2 Hi.RadioButton2.e.Text ="'". HTTP.CausesValidation = False End If End If One Listbox showing all cities. dgview.datasource=ds.e.and i add two radio buttons 1 is yes another one is No. string str="select * from table where city ='" + ddlcity. EventArgs e) { sqlConnection con= new sqlConnection(" ").fill(ds.Where as Webservices provides funtionality thru hetrogenious protocals i.And i add another one server control button . da.When u have both client and server @ your end you can use webservices and when u have either the client or the server @ your end it will be awesome if you opt Remoting 0 Hari Ganesh.So what you used to solve this problem. dgview. We can add the code in page_load If Me. How do you do that? Answer #2 protected void ddlcity_SelectedIndexChanged(object sender.TCP.tables["City"].SelectItem.Button1. V Re: How Web Services help Us? What r the difference between Remoting and webservices Answer #2 In remoting objects communicates thru homogineous protocols i.dataBind(). } How many column in table of sql server? Answer #1 We can add 1024 columns in a table in sql server 2000 .

Formatting = System. System. System.Xml.WriteStartElement("id").UI.WriteStartElement("phn").Security. write a sample code make use of xmltext writer Answer #1 using using using using using using using using using using System.what is the auto option in XML ? Answer #1 AUTO mode returns query results as nested XML elements WHT IS DIFFERENCES BETWEEN HTML CONTROLS AND SERVER CONTROLS.UTF8). System.Encoding.Web.Web.UI.WebControls. . xt.The html control is used in places like hotel menu card. xt. xt. System. xt.The server controls are used in places like railway reservation. // attribute xt.MapPath("test2.Web.WriteStartElement("city"). //start writing it xt. xt.Data.UI. xt. "100").WriteStartElement("name").WriteAttributeString("my_city". System.WriteElementString ("title".Page { protected void Page_Load(object sender.Formatting. public partial class _Default : System. System.Web. "266549560").Web.Configuration. The html controls the server is hit only on page submit.Indented. xt.WriteStartDocument(). System. System. "city").UI. xt. //initialising xmlwriter XmlTextWriter xt = new XmlTextWriter(xml1.Web."gud girl"). //element xt.Xml. Answer #1 In server controls processing would be done at server side but in html controls would be made to client side only.Web. "name"). System.WriteAttributeString("my_id".xml").UI.But for server controls on every user response the server is hit.WriteAttributeString("my_phn".WebControls. System. EventArgs e) { try { //creating a apth for writing xml string xml1 = Server.WriteAttributeString("my_name".HtmlControls.WebParts.Text.

//ending all elements xt. which will be unique throughout the application.WriteEndElement(). xt. CSS is used to give a feel and look to the web pages. In other words it's just like a thin layer above the webpage to give the web page a good appearance.SPAM.then u can add the Contenetplaceholder to add child pages custom contenet. xt. What is the difference between User Controls and Master Pages Answer #1 Both are code reduce features and reusability Purpose. Is overloading possible in web services? Answer #1 yes its possible What is CSS? What is the advantage os using CSS in ASP. xt.Close ().DRAFT.whereas user controls these r used when we have requirement on specific criteria. User Controls:Sometimes u need the functionality in ur web pages which is not possible using the Built-In Web server . xt. Master page ex: INBOX.WriteEndElement().WriteEndElement(). catch { } } } } What is an application domain? Answer #1 Application domain is something that isolates the application from interupting each other.TRASH etc in YAHOO WEBSITE 0 Venkatesh Re: What is the difference between User Controls and Master Pages Answer #2 Master pages and user controils are two different concepts.WriteEndDocument().WriteEndElement ().When we create Masterpage that is common to overall project. Master pages are used to provide the consistent layout and common behaviour for multiple pages in your applications. xt.NET Web Applications? Answer #2 CSS stands for Cascading Style Sheets.

0 Vdk Re: What is difference b/w Data Grid in ASP.net Answer #2 Insert value into array ----------------------int[] a = new int[10].1 and Gridview in 2.NET 2.. How many webforms are possible on a single webpage? Answer #1 Only One 0 Ajit Re: How many webforms are possible on a single webpage? Answer #2 n number of pages we can.It is used to define a type while leaving some details unspecified.Customised pager UI using pager template. the differences between them is >>sorting editing and paging are the additional capabilities in gridview which requires no coding while Datgrid requires the user coding .Additional column types and design time column operations.1 Generics reduces the run-time error and increases the performance. how can i insert array values and retreive in asp.NET? Answer #1 Generics are new in .0.Customized paging support.aspx extensions and u can share it in the application.i<10.net builtin controls.Generics are the replacement of "Objects" in .0 for the datagrid..Gridview has improved databinding using smart tag.i++) a[i] = i.User controlsn are those with . .In datagrid u can show more than one table with their relation while not possible in gridview.0 Answer #1 Gridview is the replacement in . What is difference b/w Data Grid in ASP.1 and Gridview in 2. for(int i=0.controls then user can create his own controls called user controls using asp.Net 1.net 2.0 Answer #2 Datagrid has itemdatabound event but in gridview it is replaced by rowdatabound. What are generics? why it is used? architecture of ASP.NET1.Net 1.

for this with the And also call the subroutine that fills the datagrid after each insert or delete so that u can see the changes at the runtime with the new alignment(i mean sorting). i < a..Write(a[i]. Dategrid filtering and sorting How can we sort all the fields at once? Answer #2 Undoubtedly u need to write a sql query order by (or) sort by.Length.Retreive value from array -------------------------for (int i = 0.. . i++) Response.ToString()).

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->