Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Satyajit Kumar Padhee

What is Data Source Control with example?


With the help of Data Source Control, we can perform the data binding operation by writing some data access code. This is used to retrive a DataReader or a DataSet object from the server and you can show that retrived data in DataGrid, DropDownLIst or in ListBox. Example: SqlConnection con = new SqlConnection(); SqlCommand cmd = new SqlCommand("Select * from Emp", con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); Grid iew1.DataSource = ds; Grid iew1.DataBind(); Difference Between Web.Config file and Global.asax ? Web.Config file is used .... 1. To specify the application settings 2. To specify the session mechanism available to use for that application. 3. To Specify the Connection strings. 4. To Specify the authentication and authorization. 5. To Specify the http handlers. 6. To Specify different providers. Global.asax file is used to specify the session and application event handlers. What do we Understand by the word "THEME" in asp.net ? Theme is a group of property settings that allows to define the look and feel of the controls to be consistent through out the Web Application . One of the advantage with themes is unlike CSS we can even Design server side controls like for example Treeview the style of rendering elements into the browser can be changed as per our wish. Here we can even change entire Web Application look and feel by just changing the theme properties. Hence these Themes could be very much useful for UI development of a web application

What is Event Bubbling in asp.net ? For every control in asp.net there are some pre defined events which could be handled for example let us take a button which has an OnClick() event when ever a single click is made to that button that event raises.

But if that particular button is in any of the following Server controls like Grid iew,Repeater,DataList etc . We cannot retrieve the button onClick() event directly. For that let us consider we have the same button in Grid iew. Here Button is the child control where as the parent control is our Gridview. These child controls do not raise by themselves when they are inside any server controls , they pass the event to the container parent and from then it is passed to our page as "ItemCommand". From the code behind we cann access button onclick event now with that ItemCommand Event of Parent control. This process of sending the child control events to parent control is said to be Event Bubbling

What is the main difference between DataSet.Clone() and DataSet.Copy() ?

DataSet.Clone() would copy only the schema of the DataSet object and it would return the DataSet object that has same struture that the previous dataset object which includes all the relations, constraints and schemas as well. This will not copy the data from the existing one to new one. The existing Dataset --private DataSet CreateMyClone(DataSet myCloneDataSet) { DataSet exampleCloneDS; exampleCloneDS = myCloneDataSet.Clone(); return exampleCloneDS; } DataSet.Copy() will copy complete code as well as the structure of the existing DataSet object. What are the Good Steps to be followed for maintaining Connection Strings in Asp.Net Web Applications ? There are some basic steps which should be followed inorder maintain Connection strings more efficiently they are . Connection strings should allways be given in web.config file itself for security resons. Not only for security but also as more accessible at multiple places. . We should never make connection strings as Declarative property for SqlDataSource control . Allways Connection strings should be stored in an Encrypted format for secure Database server

. Do not store it in a plain text format and also never store it in a .aspx page. How you can determine validity of an XML document? The Document Type Definition (DTD) or the XML Schema determines the validity of an XML document. Because the XML documents are compared with DID and schema rules as specified in that. Explain advantages and disadvantages of using detect and redirect approach to globalize the web application? The advantages are: The content file that is web forms or HTML pages can be written in the appropriate language without any complexity including the resource strings. Here the content is maintained separately, which allows different applications according to the requirement of different information. With the help of this, the user can meet their needs as it is automatically directed to sites that are likely to be geographically close. The disadvantages are: It requires the performed sections of the web application to each culture-specific website be compiled and deployed separately. It requires more exertion to maintain the stability and to debug problems across the web applications. What is the use of culture attribute of the globalization element in web.config? The main aim of this attribute is to specify the Web application which deals with various culture-dependent issues, such as date time, formatting of document etc. Here the role of globalization element is to create culture-specific Web applications. It overrides the globalization settings in the applications root Web.config file as it contains the globalization settings for each culture. To implement this, just add the Web.config files to the subordinate folders present in your application. Why this Error comes during compilation of our ASP page ? Parser Error Message: It is an error to use a section registered as allowDefinition='MachineOnly' beyond machine.config. This happens because , In our web.config file we might have declared a section that is not configurable on our shared web hosting platform. So when we get this error we have to remove that part which is not supported in the web.config file.

What are the simple Escape sequences write with their unicode Character encoding. There are 11 Different simple Escape Sequences they are : Escape Sequence = \' ,CharacterName= SingleQuote and UnicodeEncoding=0x0027 Escape Sequence = \'' ,CharacterName= DoubleQuote and UnicodeEncoding=0x0022 Escape Sequence = \\ ,CharacterName= BackSlash and UnicodeEncoding=0x005c Escape Sequence = \0 ,CharacterName= Null and UnicodeEncoding=0x0000 Escape Sequence = \a ,CharacterName= Alert and UnicodeEncoding=0x0007 Escape Sequence = \b ,CharacterName= BackSpace and UnicodeEncoding=0x0008 Escape Sequence = \f ,CharacterName= FormFeed and UnicodeEncoding=0x000c Escape Sequence = \n ,CharacterName= NewLine and UnicodeEncoding=0x000A Escape Sequence = \r ,CharacterName= CarriageReturn and UnicodeEncoding=0x000D Escape Sequence = \t ,CharacterName= HorizantalTab and UnicodeEncoding=0x0009 Escape Sequence = \v ,CharacterName= erticalTab and UnicodeEncoding=0x000B

How does the Transaction topic work in asp ? In Asp there is an Assembly called System.Transactions which contains classes that allows the applications to work under the transactions which were organised by Microsoft Distributed Transaction Coordinator (MSDTC ) and Local Transaction Manager(LTM ). This System.Transactions assembly allows both implicit and expict way of operation The Explicit programming model is based on the Transaction class and The Implicit programming model using the Transaction Scope class.

How to make an ASP page to refresh after certain time ? Inorder to make a particular page to be refreshed after a particular time at page level of the asp page we need to specify like this : <meta http-equiv="refresh" content="15" />

The above statement will make a particular page to be refreshed for every 15 seconds.

In real time if we see cricinfo webpage for every default period of time the page gets refreshed.

When it will be advisable to use html server controls and when it will be advisable to use web server controls? In general, the server controls are the part of ASP.net application. When we are using server control, then it creates an extra overhead on the server to create the control and set the values at run time. The ASP.net applications well supported to HTML controls which are static in nature and easy to use. Apart from that if a corresponding HTML control available instead of server control, then it is advisable to go for HTML control as it enhances the server performance and gives faster response. The web server controls can be used when the requirement is not achieved by the HTML server control or the available HTML controls are not sufficient to achieve the task.

What is connection pooling and how do you make your application use it? When you want to connect to the database, you have to open database connection which decreases the performance and also it is a time consuming operation. So with the help of connection pooling, you can increase the performance of the applications that is you can reuse the active database connections instead of creating new connection for each and every request made to the database. Its behavior is controlled by the connection string parameters. Below are 4 parameters which help to control connection pooling behavior. Connect Timeout Max Pool Size Min Pool Size Pooling

What is the difference between Panel and GroupBox classes in .NET? The both classes that is Panel and GroupBox can be used as a container for other controls such as check box control, radio button control etc. But the difference between these two classes is In case of Panel class captions cannot be displayed i.e. we cant set caption but in GroupBox class captions can be displayed. The Panel class can have scroll bars but GroupBox class cannot have scroll bar.

What is the Difference between Convert.ToString() and .ToString() Generally Convert.ToString() handles NULLs where as .ToString will return a Null Reference Exception. So it would be good if we use Convert.ToString() all the time for casting purposes.

Which one of the following file store the method signature information for an XML WebService ? NOTE: This is objective type question, Please click question title for correct answer.

What are the main advantages of binary serialization? The main purpose of using serialization and deserialization is to transfer the data in a linear form over a network. The advantage of using serialization is the ability of an object to be serialized into a persistent or a non-persistent storage media and then reconstructing the same object later by de-serializing the object. The Binary Serialization is faster, which supports complex objects with read only properties and even circular references. Explain the requirement of ASP.NET web services? The ASP.NET web services are used for B2B applications like authorizing employees, supplier, signing of invoice etc. These web services are the way to expose the middle tier components through internet. With the help of these components, you can communicate across the firewalls as they use SOAP as a transport protocol which helps to transmit structured data using HTTP channel. The default port is 80 through which we can easily transfer message. The web services are platform independent.

What are the different protocols used by a .Net Web Service? The protocols are normally used in .Net Web Service for communication purposes. A web service can bind with three different protocols such as Http-Get, Http-Post, and SOAP. These protocols are included in the WSDL file that is automatically generated in .NET application. It is preferable to use Http-Get and Http-Post only when name/value pairs of data is avilable. But if the data is complex in nature that is XML notes, dataset etc, then we can use SOAP which helps to serialize data in simpler form.

What is the type of struct? Can a struct inherit from another struct or class? The structs are always value types. A struct cannot be inherited from another struct or class, and also it cannot be the base of a class. But yes, in struct you can instantiate it without using a new operator. Define casting of a data type? What are the two types of data type conversions? Casting a data type is nothing but converting a variable from one data type to another data type. This can also be called as data type conversion.

There are two types of data type conversions as given below. Implicit conversions: Here the conversion is type safe i.e. no special syntax is required for this. With this you can convert from derived classes to base classes. In this conversion, there is no chance of data loss. Explicit conversions: Here the conversion requires a cast operator. Here both source and destination variables are compatible, but might be risk in data loss because of the type or size of destination variable is smaller than the source variable. Example: class clsBase=new class();

method m=clsBase; //Implicit conversion

class clsDerive=(class) m; //Explicit conversion

What is the difference between GetType and TypeOf? The GetType function, which is used to get the type of an object based on that object that is the instance of that class. It means that, this function needs parameter as an argument of object rather than class name. But in case of typeOf , we have to pass that class name as a parameter. This function is used to get the type based on a class. That is suppose you will use typeOf function with an object as a argument, then it will give you error. Examplestring str = Hello;

Type val1 = str.GetType();

Type val2 = typeof(string);

Here in the above example in both cases you will get output as true. Define Session object? The Session objects are non-persistant and it is not strongly typed. The Session objects uses the In Proc, Out Of Process or SQL Server Mode to store information. It is not only allowed for authenticated users but also allows to the unauthenticated users.

Explain what is Profile object? The Profile objects are persistent and it uses the providers model to store information. It is Strongly typed. This can be used frequently by the Anonymous users. How can you assign a Master Page dynamically? You can assign the master page dynamically with the help of Page class property called MasterPageFile . You can assign this when the page is in PreInit stage. Below is the sample code to assing master page dynamically.

void Page_PreInit(Object sender, EventArgs e)

this.MasterPageFile = "~/MasterPage.master";

How many different types of triggers available ? what are they? There are mainly 3 different types of triggers they are DML Triggers The Database operations could be done by using Insert,Update,Delete In this there are 2 different options a) After b) Insted Of DDL Triggers The Database operations that could be done using this are Create,Alter,Drop CLR Triggers User Defined Triggers.

Main advantage of URL Re-Writting ? There are 3 different advantages of URL Re-Writting they are ----1) It would make the URL quite simple and understandable for this we need to avoid

( =, ? ) in query string 2) Increase the Rank of the page through dynamic URL's 3) No extension is shown.(Security Aspect)

How do you declare an unnamed procedure within .NET? Use the DllImport attribute or a visual c# .Net declare statement to declare an unmanaged procedure for use with a .NET assembly. The DllImport attribute is found in the System.Runtime.InteropServices namespace. Describe the life cycle of a web application? When are webforms instantiated and how long do they exist? A Web application starts with the first request for a resource with in the applications boundaries. Web forms are instantiated when they are requested. They are processed by the server and are abandoned immediately after the server sends its response to the client. A web application ends after all client sessions end. What is the use of DataSet.CaseSensitive property? If the CaseSensitive property of a DataSet is set to true, then the string comparisons for all the DataTables within dataset will be case sensitive. By default the CaseSensitive property is always false. How you can roll back all the changes made to a DataSet when it was created? By invoking the DataSet.RejectChanges() method, you can undo or roll back all the changes made to a DataSet when it was created.

What is Screen Scraping ? It means reading the contents of the WebPage. Let us assume www.rediff.com website. If we browse into that site the interface which we could see includes different controls but we cannot see what is the URL of those links and what are the properties of those controls . What Screen Scraping does is that it will pull the HTML related data into the webpage.

How you can roll back all the changes made to a DataSet when it was created? By invoking the DataSet.RejectChanges() method, you can undo or roll back all the changes made to a DataSet when it was created.

What is Screen Scraping ? It means reading the contents of the WebPage. Let us assume www.rediff.com website. If we browse into that site the interface which we could see includes different controls but we cannot see what is the URL of those links and what are the properties of those controls . What Screen Scraping does is that it will pull the HTML related data into the webpage.

What is the use of DIAGNOSTICS namespace in C#.Net? It is a collection of classes which makes two options available to the development of any application they are ... 1) It will enable to Debug the application 2) It will allow to follow the execution of the application.

When were Partial Methods intorduced ? (FrameWork ) NOTE: This is objective type question, Please click question title for correct answer.

Where does Static variables store ? Static variables are stored on the Heap of the memory. It is not dependent on whether it is declared within a reference type or a value type. These variables will be in the memory till the time program ends.

What is the Difference between Internal and Protected Internal Access Modifiers? Internal : It can be accessed by any code in the same assembly but cannot be accessable in another assembly Protected Internal : It can be accessed by any code in the same assembly, or by any derived class in another assembly. For a particular project. What is the difference between Synchronous and Asynchronous HTTP Handlers? When you call for a HTTP request, unless until it finished the processing of assigned task, the Synchronous HTTP handler doesn't return any value. It will return a value after successful execution of sent request.

But in case of asynchronous handler, it will run a process independently and it will send a response to the end user. When you are working with some lengthy application processes, then it is advisable to use Asynchronous handler. Here the user doesn't need to wait until it finishes before receiving a response from the server.

How can you create your own custom HTTP handler factory class? Yes, with the help of class by implementing the IHttpHandlerFactory interface, you can create your own custom HTTP handler factory class.

What is the co-relation and difference between HTTP handlers and HTTP modules? The co-relation between HTTP handler and HTTP module is both are an integral part of the ASP.NET application. For each request is being send by the user for processing, the request will process by multiple HTTP modules and after that the request is processed by a single HTTP handler. When a request is processed by HTTP handler, then the request goes back to the user through HTTP modules. The handlers are used to process individual endpoint requests made by the user. It returns a response to a request that is identified by a file name extension. It also enables ASP.NET application to process the HTTP URL extensions and is implementing the IHttpHandler interface, which is located in the System.Web namespace. These are analogous to Internet Server Application Programming Interface (ISAPI) extensions. The modules are used to invoke all requests and responses made by the user. It is executed before and after the handler executes. It also enables user to modify each individual request. These modules implementing IHttpModule interface, which is located in the System.Web namespace. What is the difference between Named skins and Default skins? When you are applying any theme to a page, then by default the Default skin applies to all controls of same type to that page. This skin is default for a control if it does not have SkinID attribute. Suppose you create a default skin for a Calendar control, then the control skin applies to all Calendar controls on pages that use the theme. But the named skin controls have their SkinID property. It is not applying skin attributes automatically for controls by type, but it facilitates to apply explicitly a named skin to a control by changing the control's SkinID property. It allows you to set different skins for different instances of the same control in an application. Explain 3 levels at which a theme can be applied for a web application? At page level - Use the Theme or StyleSheetTheme attribute of the @ Page directive. At application level - It can be applied to all pages in an application by setting the

<pages> element in the application configuration file. At web server level - It define the <pages> element in machine.config file. This will apply the theme to all the web applications on that web server. What is the difference between themes and CSS? In case of CSS you can define only style properties but a theme can define multiple properties of a control not just style properties such as you can specify the graphics property for a control, template layout of a Grid iew control etc. The CSS supports cascading but themes does not support. The CSS cannot override the property values defined for a control but any property values defined in a theme, the theme property overrides the property values declaratively set on a control, unless you explicitly apply by using the StyleSheetTheme property. You can apply multiple style sheets to a single page but you cannot apply multiple themes to a single page. Only one theme you can apply for a single page.

How to follow the best way to secure connection strings in an ASP.NET web application? When you are working with ASP.NET applications, you should always store the connection strings in Web.config file. This is very secure. No user has rights to access web.config file from the browser. Store the connection strings as encrypted format in the configuration file. Don't store the connection strings in .aspx page. It is not recommended to set connection strings as declarative properties of the SqlDataSource control or some other data source controls.

What's the use of "Connecting to SQL Server using Integrated Security"? This is best suited to use instead of using an explicit user name and password, which helps us to avoid the possibility of the connection string being compromised and your user ID and password being exposed. Why we are storing an XML file in the applications App_Data folder? The use of storing an XML file in App_Data folder is not to return the contents of the App_Data folder in response to direct HTTP requests.

Write the steps to avoid Script Injection attacks?

Step-1: First encode the user input with the HtmlEncode methods so that the method will return HTML into its text representation. Step-2: When you are using bound fields of a Data controls, then set the BoundField object's HtmlEncode property to true which causes the Data control to encode input given by the user when you are in edit mode of that Data control.

What is an HTTP Handler? This is a process which runs in response to a request made by an ASP.NET Web application. This is also referred to as endpoint. The ASP.NET page handler processes .aspx files. When a user requests an .aspx file, then the request is processed by the page through the page handler. It is also possible to create an HTTP handler that render custom output to the browser.

What is HTTP module? These are the assemblies, and when you are sending any requests to your application then this assembly will call. This is also a part of the ASP.NET request pipeline and has access to life-cycle events throughout the request. HTTP modules are examining the incoming and outgoing requests and it takes action based on the request made by user.

What is the interface that you have to implement to create a Custom HTTP Handler? Implement IHttpHandler interface to create a synchronous handler. Implement IHttpAsyncHandler to create an asynchronous handler.

What is the use of MaintainScrollPositionOnPostBack property? When a page is posted back to the server, at that time the user is at top position of the page rather it is not redirecting to that location where the user is before redirect of the webpage. So the use of MaintainScrollPositionOnPostBack property for a Page is to set the value as true or false for scroll position in the browser after the page is postback. When the property is set to true then the user will at that position at which the user is present before redirect. So we can say the user will redirect to the same position before redirect to another page. <asp:Page MaintainScrollPositionOnPostBack="True/False" />

In which way you can retrieve original request URL when using URL rewriting or Server.Transfer in ASP.NET?

The way to retrieve original request URL is Request.ServerVariables("HTTP_X_REWRITE_URL") . It will work on all types of URL rewriting methods like ISAPI filters, HTTP Handlers or Http Modules and on Server.Transfer. Before any URI modifications, the original Request URI is saved into the HTTP header i.e. X-Rewrite-URL. This can also be retrieved in ASP.NET by using the above method.

What is difference between Common Type System and Type Safe? CTS define all of the basic types that can be used in the .NET Framework and the operations performed on those types. Type safe means preventing programs from accessing memory outside the bounds of an object's public properties. Type-safe code accesses only the memory locations which is authorized to access.

Can you programmatically store and retrieve data from ViewState? Yes, you can programmatically store and retrieve data from iewState in an ASP.NET application. Example: To save the value in iewState object iewState("Name") = txtName.text;

Retrieve the value from iewState object String strName = iewState("Name").ToString();

Is the ViewState of one page available to another page? No, the iewState of a Page is available only in that page. You cannot access iewState of one page to another page. Can the HTML controls retain State across postbacks? If no, can you make HTML controls retain State across postbacks? No, by default the HTML controls doesn't retain any state across postbacks. But yes, if you are converting HTML controls to Server Controls then you can retain HTML control State across postbacks. There are 2 ways to convert HTML control to Server Control. Right click on the HTML Control and then click "Run As Server Control" Set runat="server" attribute for the Control.

When a ViewState restoration happens and is it encoded? The iewState restoration happens during the Page_Init event. Yes, the iewState is base64 encoded. What are the three Register directive attributes used to add custom controls to a Web form? TagPrefix: The TagPrefix defines a unique namespace for an user control. If multiple user controls are present on the page having same name, then they can be differentiated with them by using this directive. It determines the group that the user control belongs to. Namespace: It is nothing but the project name and namespace within the custom control assembly that contains the controls to register. The .NET applications use the project name as an implicit namespace for controls present in the application. Assembly: This defines the name of the created assembly (.dll) that contains the custom controls. The control assembly is referenced by the Web application and it maintains a copy in the web applications 'Bin' directory. What are composite custom controls? Creating an extreme powerful control that is composite custom control which requires the combination of several server or HTML controls with in a single control class, and which can compiled with other control classes to create an assembly. That created assembly (.dll) contains custom control library. After creating, you can load into isual Studio .NET and can use as how you are using standard controls. These controls are functionally similar to user controls, but they present in their own assemblies, so you can share the same control in different projects without copying the control. However its difficult to create custom controls because you cant draw them visually with the help of isual Studio .NET.

What is a validation group and how do you create a validation group? This is a group which allows you to combine different validation controls in a single group on a page. With this, each validation group will going to perform its independent validation property as compared to other validation groups present on that page. You can create a validation group by changing the alidationGroup property to the same name for all the controls that you want to group. You can define a name to validation group, but you must have to use the same name for all controls of the group.

How a validation group works when the Page is posted?

When the page postbacks, then the Is alid property of Page class is set based on the validation controls present in the validationGroup. This group determines the caused validation occurred by the control. For example, if a button control with a validation group, let's say login group is clicked, then the Is alid property will return true if all validation controls whose alidationGroup property is set to login group are valid.

Can a DropDownList fire validation controls? Yes, a DropDownList control can fire validation control when the Causes alidation property of that validation control is set to true and the AutoPostBack property is set to true. Why SetFocusOnError property is used for a validation control? With the help of this property, you can specify the focus whether that is automatically set to the control specified by the ControlTo alidate property or not or else by using the focus feature, the validators can be configured to set focus to their associated control to be validated when a validation error occurs. It will set when the validation control unable to validate. It allows us to update the appropriate control present in the control property. It will always move focus back to the field with the error after you tab out and an error occurs.

What is InitialValue property of a RequiredFieldValidator? This property assigns the starting value for a input control. The default value is String.Empty. The validation control fails to validate, if the value of the associated input control is same as the Initial alue upon focus. With the help of this control you can make the input control as a mandatory field.

How you can invoke programmatically all validation controls on a page? You can invoke validation controls programmatically with the help of CallPage. alidate() method. These properties invoke the validation logic for each validation control in the defined validation group. When this method is invoked, it does through the validation controls associated with the Page.

You might also like