Basic net questions
1. Explain the .NET architecture.
2. How many languages .NET is supporting now? - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.
3. How is .NET able to support multiple languages? - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
4. How ASP .NET different from ASP? - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
5. Resource Files: How to use the resource files, how to know which language to use?
6. What is smart navigation? - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
7. What is view state? - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
8. Explain the life cycle of an ASP .NET page.
9. How do you validate the controls in an ASP .NET page? - Using special validation controls that are meant for this. We have Range Validator, Email Validator.
10. Can the validation be done in the server side? Or this can be done only in the Client side? - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
11. How to manage pagination in a page? - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
12. What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.
ASP.NET Interview questions
1) What is the difference between excute query and excute nonquery.?
2) one application can have only one Web config file - true or false ans – True
3) What is diffrence between debug.trace and trace.write?
Where is the information of debug stored? ANS : Debug.write is not compiled and they are meant only for debug builds.
Trace.write is compiled and can be used in Debug and Release builds of the Applications
1. What do I need to create and run an ASP.NET application?
• Windows 2000, Windows Server 2003 or Windows XP.
• ASP.NET, which can be either the redistributable (included in the .NET SDK) or Visual Studio .NET.
1. Where can I download the .NET SDK?
.NET SDK can be obtained here.
(You have to install the Microsoft .NET Framework Version 1.1 Redistributable Package before installing the .NET SDK.)
2. Are there any free IDEs for the .NET SDK?
o Microsoft provides Visual Studio 2005 Express Edition Beta for free. Of particular interest to the ASP.NET developers would be the Visual Web Developer 2005 Express Edition Beta 2 available as a free download.
o The ASP.NET Web Matrix Project (supported by Microsoft) is a free IDE for developing ASP.NET applications and is available here.
o There is also a free open-source UNIX version of the Microsoft .NET development platform called Mono available for download here.
o Another increasingly popular Open Source Development Environment for .NET is the #develop (short for SharpDevelop) available for download here.
3. When was ASP.NET released?
ASP.NET is a part of the .NET framework which was released as a software platform in 2002.
4. Is a new version coming up?
ASP.NET 2.0, Visual Studio 2005 (Whidbey), Visual Web Developer 2005 Express Edition are the next releases of Microsoft's Web platform and tools. They have already been released as Beta versions. They are scheduled to be released in the week of November 7, 2005.
5. Explain Namespace.
Namespaces are logical groupings of names used within a program. There may be multiple namespaces in a single application code, grouped based on the identifiers’ use. The name of any given identifier must appear only once in its namespace.
6. List the types of Authentication supported by ASP.NET.
o Windows (default)
o Forms
o Passport
o None (Security disabled)
7. What is CLR?
Common Language Runtime (CLR) is a run-time environment that manages the execution of .NET code and provides services like memory management, debugging, security, etc. The CLR is also known as Virtual Execution System (VES).
8. What is CLI?
The CLI is a set of specifications for a runtime environment, including a common type system, base class library, and a machine-independent intermediate code known as the Common Intermediate Language (CIL). (Source: Wikipedia.)
9. List the various stages of Page-Load lifecycle.
o Init()
o Load()
o PreRender()
o Unload()
10. Explain Assembly and Manifest.
An assembly is a collection of one or more files and one of them (DLL or EXE) contains a special metadata called Assembly Manifest. The manifest is stored as binary data and contains details like versioning requirements for the assembly, the author, security permissions, and list of files forming the assembly. An assembly is created whenever a DLL is built. The manifest can be viewed programmatically by making use of classes from the System.Reflection namespace. The tool Intermediate Language Disassembler (ILDASM) can be used for this purpose. It can be launched from the command prompt or via Start> Run.
11. What is Shadow Copy?
In order to replace a COM component on a live web server, it was necessary to stop the entire website, copy the new files and then restart the website. This is not feasible for the web servers that need to be always running. .NET components are different. They can be overwritten at any time using a mechanism called Shadow Copy. It prevents the Portable Executable (PE) files like DLLs and EXEs from being locked. Whenever new versions of the PEs are released, they are automatically detected by the CLR and the changed components will be automatically loaded. They will be used to process all new requests not currently executing, while the older version still runs the currently executing requests. By bleeding out the older version, the update is completed.
12. What is DLL Hell?
DLL hell is the problem that occurs when an installation of a newer application might break or hinder other applications as newer DLLs are copied into the system and the older applications do not support or are not compatible with them. .NET overcomes this problem by supporting multiple versions of an assembly at any given time. This is also called side-by-side component versioning.
13. Explain Web Services.
Web services are programmable business logic components that provide access to functionality through the Internet. Standard protocols like HTTP can be used to access them. Web services are based on the Simple Object Access Protocol (SOAP), which is an application of XML. Web services are given the .asmx extension.
14. Explain Windows Forms.
Windows Forms is employed for developing Windows GUI applications. It is a class library that gives developers access to Windows Common Controls with rich functionality. It is a common GUI library for all the languages supported by the .NET Framework.
15. What is Postback?
When an action occurs (like button click), the page containing all the controls within the <FORM... > tag performs an HTTP POST, while having itself as the target URL. This is called Postback.
16. Explain the differences between server-side and client-side code?
Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.
17. Enumerate the types of Directives.
o @ Page directive
o @ Import directive
o @ Implements directive
o @ Register directive
o @ Assembly directive
o @ OutputCache directive
o @ Reference directive
18. What is Code-Behind?
Code-Behind is a concept where the contents of a page are in one file and the server-side code is in another. This allows different people to work on the same page at the same time and also allows either part of the page to be easily redesigned, with no changes required in the other. An Inherits attribute is added to the @ Page directive to specify the location of the Code-Behind file to the ASP.NET page.
19. Describe the difference between inline and code behind.
Inline code is written along side the HTML in a page. There is no separate distinction between design code and logic code. Code-behind is code written in a separate file and referenced by the .aspx page.
20. List the ASP.NET validation controls?
o RequiredFieldValidator
o RangeValidator
o CompareValidator
o RegularExpressionValidator
o CustomValidator
o ValidationSummary
21. What is Data Binding?
Data binding is a way used to connect values from a collection of data (e.g. DataSet) to the controls on a web form. The values from the dataset are automatically displayed in the controls without having to write separate code to display them.
22. Describe Paging in ASP.NET.
The DataGrid control in ASP.NET enables easy paging of the data. The AllowPaging property of the DataGrid can be set to True to perform paging. ASP.NET automatically performs paging and provides the hyperlinks to the other pages in different styles, based on the property that has been set for PagerStyle.Mode.
23. Should user input data validation occur server-side or client-side? Why?
All user input data validation should occur on the server and minimally on the client-side, though it is a good way to reduce server load and network traffic because we can ensure that only data of the appropriate type is submitted from the form. It is totally insecure. The user can view the code used for validation and create a workaround for it. Secondly, the URL of the page that handles the data is freely visible in the original form page. This will allow unscrupulous users to send data from their own forms to your application. Client-side validation can sometimes be performed where deemed appropriate and feasible to provide a richer, more responsive experience for the user.
24. What is the difference between Server.Transfer and Response.Redirect?
o Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
o Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.
25. What is an interface and what is an abstract class?
In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.
26. Session state vs. View state:
In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:
o Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.
o Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.
o Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.
27. Can two different programming languages be mixed in a single ASPX file?
ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.
28. Is it possible to see the code that ASP.NET generates from an ASPX file?
By enabling debugging using a <%@ Page Debug="true" %> directive in the ASPX file or a <compilation debug="true"> statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files).
29. Can a custom .NET data type be used in a Web form?
This can be achieved by placing the DLL containing the custom data type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.
30. List the event handlers that can be included in Global.asax?
o Application start and end event handlers
o Session start and end event handlers
o Per-request event handlers
o Non-deterministic event handlers
31. Can the view state be protected from tampering?
This can be achieved by including an @ Page directive with an EnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the <pages enableViewStateMac="true" /> statement in the Web.config file.
32. Can the view state be encrypted?
The view state can be encrypted by setting EnableViewStateMac to true and either modifying the <machineKey> element in Machine.config to <machineKey validation="3DES” /> or by adding the above statement to Web.config.
33. When during the page processing cycle is ViewState available?
The view state is available after the Init() and before the Render() methods are called during Page load.
34. Do Web controls support Cascading Style Sheets?
All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.
35. What namespaces are imported by default in ASPX files?
The following namespaces are imported by default. Other namespaces must be imported manually using @ Import directives.
o System
o System.Collections
o System.Collections.Specialized
o System.Configuration
o System.Text
o System.Text.RegularExpressions
o System.Web
o System.Web.Caching
o System.Web.Security
o System.Web.SessionState
o System.Web.UI
o System.Web.UI.HtmlControls
o System.Web.UI.WebControls
36. What classes are needed to send e-mail from an ASP.NET application?
The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's System.Web.Mail namespace.
37. Why do some web service classes derive from System.Web.WebServices while others do not?
Those Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.
38. What are VSDISCO files?
VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.
39. How can files be uploaded to Web pages in ASP.NET?
This can be done by using the HtmlInputFile class to declare an instance of an <input type="file" runat="server"/> tag. Then, a byte[] can be declared to read in the data from the input file. This can then be sent to the server.
40. How do I create an ASPX page that periodically refreshes itself?
The following META tag can be used as a trigger to automatically refresh the page every n seconds:
<meta http-equiv="Refresh" content="nn">
41. How do I initialize a TextBox whose TextMode is "password", with a password?
The TextBox’s Text property cannot be used to assign a value to a password field. Instead, its Value field can be used for that purpose.
<asp:TextBox Value="imbatman" TextMode="Password"
ID="Password" RunAt="server" />
42. Why does the control's PostedFile property always show null when using HtmlInputFile control to upload files to a Web server?
This occurs when an enctype="multipart/form-data" attribute is missing in the <form> tag.
43. How can the focus be set to a specific control when a Web form loads?
This can be achieved by using client-side script:
document.forms[0].TextBox1.focus ()
The above code will set the focus to a TextBox named TextBox1 when the page loads.
44. How does System.Web.UI.Page's IsPostBack property work?
IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a __VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.
45. What is WSDL?
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org)
46. What is UDDI?
UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.
47. Is it possible to generate the source code for an ASP.NET Web service from a WSDL?
The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.
Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.
48. Why do uploads fail while using an ASP.NET file upload control to upload large files?
ASP.NET limits the size of file uploads for security purposes. The default size is 4 MB. This can be changed by modifying the maxRequestLength attribute of Machine.config's <httpRuntime> element.
49. Describe the difference between inline and code behind.
Inline code is written along side the HTML in a page. Code-behind is code written in a separate file and referenced by the .aspx page.
51. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
52. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Valid answers are:
o A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
o A DataSet is designed to work without any continuing connection to the original data source.
o Data in a DataSet is bulk-loaded, rather than being loaded on demand.
o There's no concept of cursor types in a DataSet.
o DataSets have no current record pointer You can use For Each loops to move through the data.
o You can store many edits in a DataSet, and write them to the original data source in a single operation.
o Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
53. What’s a bubbled event?
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.
54. What data types do the RangeValidator control support?
Integer, String, and Date.
55. Explain what a diffgram is, and a good use for one?
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.
56. What is the transport protocol you use to call a Web service?
SOAP (Simple Object Access Protocol) is the preferred protocol.
57. What is ViewState?
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.
58. What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.
59. What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.
60. Differences Between XML and HTML?
Anyone with a fundamental grasp of XML should be able describe some of the main differences outlined in the table below
XML HTML
User definable tags Defined set of tags designed for web display
Content driven Format driven
End tags required for well formed documents End tags not required
Quotes required around attributes values Quotes not required
Slash required in empty tags Slash not required
61. Give a few examples of types of applications that can benefit from using XML.
There are literally thousands of applications that can benefit from XML technologies. The point of this question is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.
62. What is DOM and how does it relate to XML?
The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.
63. What is SOAP and how does it relate to XML?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.
64. Can you walk us through the steps necessary to parse XML documents?
Superficially, this is a fairly basic question. However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate's response.
65. What are possible implementations of distributed applications in .NET?
.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.
66. What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of informaion. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.
67. What’s a proxy of the server object in .NET Remoting?
It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.
68. What are remotable objects in .NET Remoting?
Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.
69. What are channels in .NET Remoting?
Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.
70. What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.
71. What is a formatter?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.
72. Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?
Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
73. What’s SingleCall activation mode used for?
If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.
74. What’s Singleton activation mode?
A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.
75. How do you define the lease of the object?
By implementing ILease interface when writing the class code.
76. Can you configure a .NET Remoting object via XML file?
Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.
77. How can you automatically generate interface for the remotable object in .NET with Microsoft tools?
Use the Soapsuds tool.
In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?
Answer 1. Object Initialization
2. Load Viewstate Data
3. LoadPostData Processes Postback Data
4. Object Load
5. Raise PostBack Change Events
6. Process Client-Side PostBack Event
7. Prerender the Objects
8. ViewState Saved
9. Render To HTML
10. Disposal
What are the disadvantages of viewstate/what are the benefits
Ans: Viewstate has lots of advantages and as well as disadvantages, so you need to weigh carefully before making the decision to use it. As view state doesnt require any server resources for its operation. It is passed to the client during every postback as an hidden element. Since it is added with every page, it adds few Kbytes to the page. This effects the loading of the page in the client. Other main problem with Viewstate is, since it is passed as plain text to the client. Anybody can tamper this value, because of this you shouldnt store any important data in the viewstate. View state is one of the most important features of ASP.NET, not so much because of its technical relevance, but more because it makes the magic of the Web Forms model possible. However, if used carelessly, view state can easily become a burden. Although ViewState is freely accessible in a hidden field called __VIEWSTATE, the view state information is not clear text. By default, a machine-specific authentication code is calculated on the data and appended to the view state string. The resulting text is then Base64 encoded only, but not encrypted. In order to make the view state more secure, the ASP.NET @Page directive supports an attribute called EnableViewStateMac whose only purpose is detecting any possible attempt at corrupting original data.
What are delegates?
Ans:
A delegate is a class that can hold a reference to a method. Unlike other classes, a delegate class has a signature, and it can hold references only to methods that match its signature. A delegate is thus equivalent to a type-safe function pointer or a callback.
What is delay signing?
Ans:The strong name contains the public/private key pair. But at the developement time, if we want to use only the public key we should use this concept.
Delay signing is the high-end process. If we want to create the private key at the instalation time, we should use this concept.
For this we set the "deley signing=true" in the assemblyinfo.vb/cs.
What is CLR?
Ans:First of all, VB.NET provides managed code execution that runs under the Common Language Runtime (CLR), resulting in robust, stable and secure applications. All features of the .NET framework are readily available in VB.NET.
The CLR takes care of garbage collection i.e. the CLR releases resources as soon as an object is no more in use. This relieves the developer from thinking of ways to manage memory. CLR does this for them.
What is the life cycle of an asp.net page?
Ans:The Life Cycle represents all the Events and Methods that are called from Initializing the Page to Unloading the Page. Stages and corresponding events in the life cycle of the ASP.NET page cycle: Stage Events/Method====================== ===========================Page Initialization Page_InitView State Loading LoadViewStatePostback data processing LoadPostDataPage Loading Page_LoadPostBack Change Notification RaisePostDataChangedEventPostBack Event Handling RaisePostBackEventPage Pre Rendering Phase Page_PreRenderView State Saving SaveViewStatePage Rendering Page_RenderPage Unloading Page_UnLoad
What is Viewstate?
Ans:The web is a stateless medium - state is not maintained between client requests by default. Technologies must be utilized to provide some form of state management if this is what is required of your application, which will be the case for all but the simplest of web applications. ASP.NET provides several mechanisms to manage state in a more powerful and easier to utilize way than classic ASP.
Page level state is information maintained when an element on the web form page causes a subsequent request to the server for the same page - referred to as 'postback'. This is appropriately called ViewState as the data involved is usually, though not necessarily, shown to the user directly within the page output.
The Control.ViewState property is associated with each server control in your web form and provides a dictionary object for retaining values between such multiple requests for the same page. This is the method that the page uses to preserve page and control property values between round trips.
When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field. When the page is posted back to the server, the page parses the view state string at page initialization and restores property information in the page.
ViewState is enabled by default so if you view a web form page in your browser you will see a line similar to the following near the form definition in your rendered HTML:
ViewState offers a substantial improvement over the two competing techniques for state management via the client: standard hidden fields and cookies, in that ViewState is not limited to the storage of simple values. You can use ViewState to store any object as long as it is serializable, and the standard VB.NET types are. Serialization is the process of storing an object's data and other information necessary to reconstruct the object later.
There is a further complication: a type that either is serializable or has a TypeConverter defined for it can be persisted in ViewState. However, types that are only serializable are slower and generate a much larger ViewState than those that have a TypeConverter. The TypeConverter class provides a unified way of converting types of values to other types, as well as for accessing standard values and subproperties.
ViewState is serialized using a limited object serialization format that is optimized for primitive types, and for String, ArrayList, and HashTable types. You may want to consider these issues if page performance concerns are keys
How Dataadapter.fill works?
Ans: Data Adapter act as amiddleman between the dataset and data Base. The fill method automatically open the connection and when the dataset is filled properly then the coonection is closed. This method fetch the data from the database
What is diff. between ASP State Management and ASP.NET State Management?(Imp) 19. How can we pass info between 2 asp.net pages?
Ans: In Distributed network architecture ASP has only one Type of Session Management which can be expressed as InProcess Session State, Where as in .NET architecture ASP.NET Session Management can be done is different ways as 1. In-Process Session Management2. Out-Process Session Management3. Sql-Server Session ManagementIn In-Process Session Management both the Application and the Session will run under the Same Process, where as in Out-
Process Session Management Application and the Session will run in different processes. Advantage of Out-Process is that event though the Application is Restared due to any reason the Sessions Assosiated with that application will not be destructed but where as in In-Process Session Management the Session State will be Lost along with the Application.In Sql-Server Session Management, the Session is Maintained in SQLSERVER Database.
Trace and Debug belongs to which namespaces?
Ans:System.Diagnostics
What is event bubbling?
Ans: Event Bubbling is nothing but events raised by child controls is handled by the parent control. Example: Suppose consider datagrid as parent control in which there are several child controls.There can be a column of link buttons right.Each link button has click event.Instead of writing event routine for each link button write one routine for parent which will handlde the click events of the child link button events.Parent can know which child actaully triggered the event.That thru arguments passed to event routine. " Happy programming"
Please brief not about XSD,XSLT & XML.
Ans: XSD stands for XML Schema Definition.It define the structure of the XML file and the elements and attributes it contains.The datatype of the elements.So that when u populate XML data into dataset, the dataset can treat elements differently based on their type.If XSD is not present dataset treats all elements as string type. XSLT stands for XML style sheet lang tranformation.It is lang used for transforming XML data in one format to another format.Example XML data into HTML format. XSLT uses XPath to identify the elements in XML doc and transform those to desired format
How to create dynamic Gridview?
Ans:Many times we have the requirement where we have to create columns dynamically.
This article describes you about the dynamic loading of data using the DataTable as the datasource.
Details of the Grid
Let’s have a look at the code to understand better.
Create a gridview in the page,
Drag and drop the GridView on to the page
Or
Manually type GridView definition in the page.
public partial class _Default : System.Web.UI.Page
{
#region constants
const string NAME = "NAME";
const string ID = "ID";
#endregion
protected void Page_Load(object sender, EventArgs e)
{
loadDynamicGrid();
}
private void loadDynamicGrid()
{
#region Code for preparing the DataTable
//Create an instance of DataTable
DataTable dt = new DataTable();
//Create an ID column for adding to the Datatable
DataColumn dcol = new DataColumn(ID ,typeof(System.Int32));
dcol.AutoIncrement = true;
dt.Columns.Add(dcol);
//Create an ID column for adding to the Datatable
dcol = new DataColumn(NAME, typeof(System.String));
dt.Columns.Add(dcol);
//Now add data for dynamic columns
//As the first column is auto-increment, we do not have to add any thing.
//Let's add some data to the second column.
for (int nIndex = 0; nIndex < 10; nIndex++)
{
//Create a new row
DataRow drow = dt.NewRow();
//Initialize the row data.
drow[NAME] = "Row-" + Convert.ToString((nIndex + 1));
//Add the row to the datatable.
dt.Rows.Add(drow);
}
#endregion
//Iterate through the columns of the datatable to set the data bound field dynamically.
foreach (DataColumn col in dt.Columns)
{
//Declare the bound field and allocate memory for the bound field.
BoundField bfield = new BoundField();
//Initalize the DataField value.
bfield.DataField = col.ColumnName;
//Initialize the HeaderText field value.
bfield.HeaderText = col.ColumnName;
//Add the newly created bound field to the GridView.
GrdDynamic.Columns.Add(bfield);
}
//Initialize the DataSource
GrdDynamic.DataSource = dt;
//Bind the datatable with the GridView.
GrdDynamic.DataBind();
}
}
Send Push Notification using C#
5 years ago
1 comment:
Cool stuff... Keep it up...
Post a Comment