Monday, December 10, 2007

Event Vs Delegate:::::::::::

An event is an event. A "delegate" assigns a particular event handler to an object instance. Thus, when an object event happens, the proper procedure/method is called.

An example might help. I frequently code things so that a single method is called for all instances of a class. No matter which button is clicked, call my generic "button_click" method. That method will use the event arguments to determine which button was actually clicked.In order to assign all button click events to a single method, I have to code the delegates.

ASPNET interview questions::::::::::
http://www.dotnetquestion.com/DOTNETFRAMEWORK/Dot%20Net%20Faramework%20Interview%20questions%201-5.html

Why Interface:::
An interface is a contract. When you design an interface, you're saying "if you want to provide this capability, you must implement these methods, provide these properties and indexers, and support these events." The implementer of the interface agrees to the contract and implements the required elements.

NOTE::::::::
foreach_(_) implements both IEnumerable and IEnumerator

C# .net questions::::
http://p3net.mvps.org/CHowSharp/2007/March/03182007.aspx

Authentication::::::::: @ User Level
Authorization:::::::::: @ Account Level

What is the difference bw hosting a application using virtual directory and without creating the virtual directory?

using virtual directory, v neednt keep updating the absolute path if at all there is ne change, but hosting it directly, whene ever there is a change in the path, v need to update it accordingly

All abt masterpages:::::::::::::
http://www.codeproject.com/aspnet/ImplementMasterPages.asp
FAQs' on .net

If I return out of a try/finally in C#, does the code in the finally-clause run? - Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs

How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:

_using _System;
_[_assembly _:_ _MyAttributeClass_]_ _class X _{_}_

Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.

How do you mark a method obsolete? -
_[_Obsolete_]_ _public _int _Foo_(_)
_{..._}
or
_[_Obsolete_(_\"This is a message describing why this method is obsolete_\_")] _public _int _Foo_(_) _{...}
Note: The O in Obsolete is always capitalized.

How do you directly call a native function exported from a DLL? - Here’s a quick example of the DllImport attribute in action:

_using _System._Runtime._InteropServices; _\_
_class _C
{
_[_DllImport_(_\_"user32.dll_\_")_]
_public _static _extern _int _MessageBoxA_(_int _h, _string _m, _string _c, _int _type_);
_public _static _int _Main()
{ _return _MessageBoxA_(_0, _\_"Hello World!_\_", _\_"Caption_\_", 0);
}
}

This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.

Which of these statements correctly declares a two-dimensional array in C#?
int[,] myArray;

How does assembly versioning in .NET prevent DLL Hell?
.NET allows assemblies to specify the name AND the version of any assemblies they need to run.

In the NUnit test framework, which attribute must adorn a test class in order for
it to be picked up by the NUnit GUI?
TestFixtureAttribute

Which of the following operations can you NOT perform on an ADO.NET DataSet?
A DataSet can be synchronised with the database. [CAN]
A DataSet can be synchronised with a RecordSet. [CANNOT]
A DataSet can be converted to XML. [CAN]
You can infer the schema from a DataSet. [CAN]

How can you tell the application to look for assemblies at the locations other than its own install?
Use the directive in the XML .config file for a given application.
_<_probing _privatepath_="_”_c:\mylibs;">
should do the trick.
Or you can add additional search paths in the Properties box of the deployed application.

What is delay signing?
Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development
All abt Delegates:::::::::::
http://www.codeproject.com/csharp/event_fundamentals.asp#3.1DefinitionandUsageofDelegates3

All abt Web.config file::::::::
http://www.dotnethero.com/hero/application/webconfig.aspx?nmx=5_1

All abt global.asax file:::::::::::
http://www.dotnethero.com/hero/application/globalasax.aspx?nmx=5_2

Dynamic Loading of User Control with ViewState Preserved:::::::::::::::
http://www.aspnet4you.com/Articles.aspx?ArticleID=5032

To Copy a datatable 2 another:::::::::::
http://www.dotnet247.com/247reference/msgs/48/243916.aspx

To add a new column @ a particular index::::::
http://blah.winsmarts.com/2006/05/20/loadcontrol-a-usercontrol--and-pass-in-constructor-parameters.aspx
What’s a bubbled event? ::::::::::::::::
a bubbled event is the process of moving an event up the control hierarchy, from a control low in the hierarchy, such as a button in the datagrid ans prelocating it upto an ancestor control

How function overriding works in C# and what is shadowing?:::::::::::
This article explains what is Shadowing and how to achieve shadowing in C#? I mean overriding concept using override and new keywords of C#

Introduction
This article will introduce you with a very good concept of shadowing in C#.
Shadowing is a concept of polymorphism usage in Object Oriented Programming.

What is Shadowing?
Shadowing is a concept of polymorphism usage in Object Oriented Programming.This is a concept related to over-riding functions at run-time or making a shadow of the object's methods in the inherited classes.

Implementation of override to override a method
Suppose you have a base class ClassA in which you have written a method MethodA. Now, if you want to inherit this class in a ClassB and use MethodA then the MethodA declared in ClassA will be used but if you override this method in your inherited class classB then it will be over-ridden and the implementation of classB will be used whenever we use it from classB and the implementation of classA will be used whenever we use it from a instance of classA.

_#_define _TRACE
_using _System;
_using _System._Diagnostics;
_using _System._IO;

_public _class _ClassA
{
_public _virtual _void _MethodA_()
{
_Trace._WriteLine_(_"_BaseClass MethodA_"_);
}
}

_public _class _ClassB :_ClassA
{
_public _override _void _MethodA()
{
_Trace._WriteLine_(_"_SubClass MethodA overridden_"_);
}
}

//implementation class for using the above defined classes

_public _class _TopLevel
{
_static _void _Main(_string[] _args)
{
_TextWriter _tw = _Console._Out;
_Trace._Listeners._Add_(_new _TextWriterTraceListener_(_tw_)_);
_ClassA _obj = _new_ _ClassB(); \
_obj._MethodA(); // Output will be “Subclass MethodA overridden”
}
}

Shadowing instead of overriding
Upto now the code shown was for overriding a base class method with the child class method, But what will happen If you want to provide the base class behaviour instead, use the new directive, with or without virtual at the base class Is this possible in C#? Yes, it is and that is the concept of shadowing in C# using a keyword "new' which is a modifier used instead of "override".

Check out in the code below
_public _class _ClassA
{ _public _virtual _void _MethodA()
{ _Trace._WriteLine_(_"_BaseClass MethodA"_)_;
}
}

_public _class _ClassB :_ClassA
{
_public _new _void _MethodA()
{
_Trace._WriteLine_(_"_SubClass MethodA overridden_"_);
}
}

//implementation class for using the above defined classes

_public _class _TopLevel
{
_static _void _Main_(_string[] _args)
{
_TextWriter _tw = _Console._Out;
_Trace._Listeners._Add_(_new _TextWriterTraceListener_(_tw_)_);
_ClassA _obj = _new _ClassB_();
_obj._MethodA_(); // Outputs “Class A Method"
_ClassB _obj1 = _new _ClassB();
_obj._MethodA_(); // Outputs “SubClass ClassB Method”
}
}
ASP.NET Internals – IIS and the Process Model:::::::::::::::::::
http://dotnetslackers.com/articles/iis/ASPNETInternalsIISAndTheProcessModel.aspx#162
Page level Tracing::::::::::::::::::



ASP.NET tracing can be enabled on a page-by-page basis by adding "_Trace=_true" to the Page directive in any ASP.NET page:



<_%_@ _language="_" _trace="_" _tracemode_ =" _" _inherits =" _" _codefile="_">



Additionally, you can add the TraceMode attribute that sets SortByCategory or the default,
SortByTime. You can use SortByTime to see the methods that take up the most CPU time for your application. You can enable tracing programmatically using the Trace.IsEnabled property.




Application Tracing::::::::::::::::::::::You can enable tracing for the entire application by adding tracing settings in web.config. In below example, _pageOutput=_"_false" and requestLimit=_"_20" are used, so trace information is stored for 20 requests, but not displayed on the page because pageOutput attribute is set to false.



<_configuration>

<_appsettings/>

<_connectionstrings/>

<_system._web>

<_compilation _debug="_">

<_authentication _mode="_">

<_trace _enabled ="_" _pageoutput ="_" _requestlimit ="_" _tracemode ="_">
<_/_system._web>

<_/_configuration>

The page-level settings take precedence over settings in Web.config, so if enabled=_"_false" is set in Web.config but trace=_"_true" is set on the page, tracing occurs.

Viewing Trace Data::::::::::::
Tracing can be viewed for multiple page requests at the application level by requesting a special page called trace.axd. When ASP.NET detects an HTTP request for trace.axd, that request is handled by the TraceHandler rather than by a page.

Create a website and a page, and in the Page_Load event, call Trace.Write(). Enable tracing in Web.config as shown below.

<_system.web>
<_compilation _debug="_">
<_authentication _mode="_">
<_trace _enabled ="_" _pageoutput ="_">


_protected _void _Page_Load_(_object _sender, _EventArgs _e)
{
_System.Diagnostics.Trace.Write_(_"This is Page_Load method!"_);
}


Trace.axd::::::::::: Page output of tracing shows only the data collected for the current page
request. However, if you want to collect detailed information for all the requests then we need to use Trace.axd. We can invoke Trace.axd tool for the application using the following URL
http://localhost/application-name/trace.axd. Simply replace page name in URL with Trace.axd. That is, in our case. We should use following URL (Address bar) for our application as shown below.
What are the basic differences between user controls and custom controls?

Now that you have a basic idea of what user controls and custom controls are and how to create them, let's take a quick look at the differences between the two.

Deployment::::::::::: Designed for single-application scenarios
Deployed in the source form (.ascx) along with the source code of the application


If the same control needs to be used in more than one application, it introduces redundancy and
maintenance problems Designed so that it can be used by more than one application


Deployed either in the application's Bin directory or in the global assembly cache

Distributed easily and without problems associated with redundancy and maintenance

Creation::::::::::::::: Creation is similar to the way Web Forms pages are created; well-suited for rapid application development (RAD)

Writing involves lots of code because there is no designer support

Content:::::::::::::::: A much better choice when you need static content within a fixed layout, for example, when you make headers and footers

More suited for when an application requires dynamic content to be displayed; can be reused across an application, for example, for a data bound table control with dynamic rows

Design::::::::::::::::: Writing doesn't require much application designing because they are authored at design time and mostly contain static data

Writing from scratch requires a good understanding of the control's life cycle and the order in
which events execute, which is normally taken care of in user controls


REFERENCE::::: http://support.microsoft.com/kb/893667
Friend and Protected Friend Function::::::::::::::::::::::::::::::::
Friend and Protected Friend are nothing but Internal and Protected Internal in C#......., its that way in VB.NET

User Contrls vs Custom Controls:::::::::::::::::::::::::::
The main difference between the two controls lies in ease of creation vs. ease of use at design time.
Web user controls are easy to make, but they can be less convenient to use in advanced scenarios. Web user controls can be developed almost exactly the same way that you develop Web Form pages.

Like Web Forms, user controls can be created in the visual designer or they can be written with code separate from the HTML. They can also support execution events. However, since Web user controls are compiled dynamically at run time they cannot be added to the Toolbox and they are represented by a simple placeholder when added to a page.

This makes Web user controls harder to use if you are accustomed to full Visual Studio .NET
design-time support, including the Properties window and Design view previews. Also the only way to share the user control between applications is to put a separate copy in each application, which takes more maintenance if you make changes to the control.


Web custom controls are compiled code, which makes them easier to use but more difficult to create. Web custom controls must be authored in code. Once you have created the control you can add it to the Toolbox and display it in a visual designer with full Properties window support and all the other design-time features of ASP.NET server controls. In addition you can install a single copy of the Web custom control in the global assembly cache and share it between applications, which make maintenance easier
State Management in an ASP .Net application. :::::::::::::::::::::::::::

When users visit Web sites it becomes necessary to maintain session related and controls related information. In an HTTP exchange between a browser and a remote host, session related information which identifies state, such as a unique session ID, information about the user's preferences or authorisation level is preserved. Note that sessions are maintained in the data being exchanged.

State Management is the process by which we maintain session related information and additional information about the controls and its state. The necessity of state management arises when multiple users request for the same or different Web Pages of a Web Site.

State management can be accomplished using Client Side options or the Server side options.

Client Side State Management Options::::::

Client Side State Management involves storing information either on a Web page or on a Client
computer. There are four ways to manage states.


View State
Hidden Form Fields
Cookies
Query String

View State
In this method, the ViewState property that is inherited from the base Control class is used to
automatically save the values of the page and of each control prior to rendering of the page.
ViewState is implemented with a hidden form field called the _VIEWSTATE, which is automatically created in every Web Form page. When ASP.Net executes a Web page on a Web Server, the values stored in the ViewState property of the page and controls on it are collected and formatted into a single encoded string. The encoded string is then assigned to the Value attribute of the hidden form field _VIEWSTATE and is sent to the client as a part of the Web page.


Hidden Form Fields
In ASP.Net we can use the HTML standard hidden fields in a Web Form to store page-specific
information. A hidden field does not render in a Web browser. However, we can set the properties of the hidden field. When a page is submitted to the server, the content of the hidden field is sent in the HTTP Form collection along with values of other controls.


Cookies
A cookie is a small data structure used by a Web server to deliver data to a web client. A cookie
contains page specific information that a Web server sends to a client along with Page output.
Cookies are used to keep track of each individual user who accesses the web page across a HTTP connection.


Query String
The Query string is a part of the request that appears after the Question mark (?) character in the URL. A query string provides a simple way to pass information from one page to another.


Server Side State Management Options ::::::::::::::::::::

Application State
ASP.Net provides application state as a means of storing global application specific information.
The information in the application state is stored in a key value pair and is used to maintain data consistency between server round trips and between pages.

Session State
In this option session state used to store session specific information for a Web site. In session
state, the scope fo session state is limited to the current browser session. In case, many users are accessing the same Web application, each will have a different session state. If a user exits from a Web applicatin and returns later, it will be a different session state.


Database Support
Another option is the database support option. Database support is used in combination with cookies or session state. The database used is usually a relational database.

.NET 3.0:::::::::::::::::::::::::::::::::

NET Framework 3.0, formerly called WinFX, includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems. It is also available for Windows XP SP2 and Windows Server 2003 as a download. There are no major architectural changes included with this release; .NET Framework 3.0 includes version 2.0 of the Common Language Runtime.

.NET Framework 3.0 consists of four major new components:

Windows Presentation Foundation (WPF), formerly code-named Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.

Windows Communication Foundation (WCF), formerly code-named Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.

Windows Workflow Foundation (WWF) allows for building of task automation and integrated transactions using workflows.

Windows CardSpace (WCS), formerly code-named InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website.
Feature SQL Server 2000 SQL Server 2005:::::::::::::::::::::::::::

Server Programming Extensions Limited to extended stored procedures, which are difficult to write and can impact the server stability. The incorporation of the CLR into the relational engine allows managed code written in .NET languages to run. Different levels of security can protect the server from poorly written code.

T-SQL Error Handling Limited to checking @@error, no much flexibility. Addition of TRY/CATCH allows more mature error handling. More error_xx functions can gather additional information about errors.T-SQL Language SQL Language enhanced from previous versions providing strong data manipulation capabilities. All the power of SQL Server 2000 with the addition of CTEs for complex, recursive problems, enhanced TOP capabilities, PIVOT/APPLY/Ranking functions, and ROW_NUMBERAuditing Limited support using triggers to audit changes. Robust event handling with EVENT NOTIFICATIONS, the OUTPUT clauses, and DDL triggers.

Large Data Types Limited to 8k for normal data without moving to TEXT datatypes. TEXT is hard to work with in programming environments. Includes the new varchar(max) types that can store up to 2GB of data in a single column/row.

XML Limited to transforming relational data into XML with SELECT statements, and some simple query work with transformed documents. Native XML datatype, support for schemas and full XPATH/XQUERY querying of data.

ADO.NET v1.1 of ADO.NET included enhancements for client development. v2 has more features, including automatic failover for database mirroring, support for multiple active result sets (MARS), tracing of calls, statistics, new isolation levels and more.

Messaging: No messaging built into SQL Server. Includes Service Broker, a full-featured asynchronous messaging system that has evolved from Microsoft Message Queue (MSMQ), which is integrated into Windows.

Reporting Services An extremely powerful reporting environment, but a 1.0 product. Numerous enhancements, run-time sorting, direct printing, viewer controls and
an enhanced developer experience.

ETL DTS is a very easy to use and intuitive tool. Limited capabilities for sources and
transformations. Some constructs, such as loops, were very difficult to implement. Integration
Services is a true programming environment allowing almost any source of data to be used and many more types of transformations to occur. Very complex environment that is difficult for non-DBAs to use. Requires programming skills.


Full-Text Search Workable solution, but limited in its capabilities. Cumbersome to work with in many situations. More open architecture, allowing integration and plug-ins of third party extensions. Much more flexible in search capabilities
Session Variables are not getting captured on deployment?????????????

Add the following in the HTTP Header of the virtual directory::::::::::::::::
p3p -- Custom Header Name
CP=123 -- Custom Header Value

All abt design patterns definitions::::::::::::::::::::::::.

http://en.wikipedia.org/wiki/Design_Patterns#Creational_patterns.2C_Chapter_3
All abt mutex in .net::::::::::::::::::::

http://msdn2.microsoft.com/en-us/library/system.threading.mutex.aspx

All abt Master PAges in .net::::::::::::::::

http://www.odetocode.com/Articles/450.aspx

All abt Destructors in C# :::::::::::::::::::::

http://msdn2.microsoft.com/en-us/library/66x5fx1b(VS.80).aspx

Add new row concept:::::::::::::::::::::

http://www.eggheadcafe.com/articles/20060513.asp
Having 2 different files with 2 different languages in app_code folder:::::::::::::::::::::::::::

put all CS files in CS folder under app_code
put all VB files in VB folder under app_code
and do put the following in web.config file

<_compilation _debug="_">
<_codesubdirectories>
<_add _directoryname="_">
<_add _directoryname="_">
<_/_codesubdirectories>
<_/_compilation>
Differences bw Session and View State::::::::::::::::::::::::::::::::

Session, View State both stores state information. This is particularly of importance as HTTP is generally stateless what this effcetively means is it does not link requests from same user.

View State is
Page Specific,
control Specific,
Simple Stored in hidden field,
No Server Resource is consumed,
Good for Web Farm,
However page load will slow down, Can be tampered, Not accessible from other pages

Session is Stored in Server. (Potentially can eat up lot of resource)
Accessible from other pages

How to Register User Controls and Custom Controls in Web.config:::::::::::::::

u neednt register user controls in every page of a webapplication, instead register it in web.config as below
-------------------------------------------------------------------------------
<_system._web>
<_pages>
<_controls>
<_add _tagprefix="_" _src="_" _tagname="_header">
<_add _tagprefix="scottgf" _src="_~/_Controls/_Footer._ascx" _tagname="_footer">
<_/_controls>
<_/_pages><_/_system._web>
-------------------------------------------------------------------------------
Use this in the webpage as below
-------------------------------------------------------------------------------

<_html>
<_body>
<_form _id="_form1" _runat="_server">
<_scottgu:_header _id="_MyHeader" _runat="_server">
<_/_form>
<_/_body>
<_/_html>
-------------------------------------------------------------------------------
Reference::::: http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx

Top Ten New and Exciting Features in ASP.NET 2.0:::::::::::::::::

http://www.theserverside.net/tt/articles/showarticle.tss?id=WhatsNewASPNET

TO enable readonly and then read the same for a aspnet control:::::::::::::::::vvvvvvvvvimp

_txtFromDate._Attributes._Add("_ReadOnly", "_ReadOnly");
_txtToDate._Attributes._Add("_ReadOnly", "_ReadOnly");

Hence, set _readonly="_readonly", so v can even retrieve the value. If v say _readonly=_true, then it can just be viewed but never be able to get the value.


NOTE::
Cache::::::: not user specific
Session::::: user specific
Command object :::::::: used to command the database


.NEt 3.0 overview::::::::::::::::::::::::::::::::::::
http://nilangshah.wordpress.com/2007/07/10/net-framework-30-introduction-and-useful-resources/

Master page tricks and tips:::::::::::::
http://www.odetocode.com/Articles/450.aspx

NOTE:::::::::::::::::::::

Whenever master page being used along a date picker, the selected date cant be picked on to the date text box. Hence, use the following 3rd party dll which will not discriminate date picker and the text box, which on selection of a date shall automatically fetches it on the text box

Reference: http://www.codeproject.com/useritems/ASPNET_JS_Calendar.asp


Note::::::::::::::::::vvvvvvvvvvvvimp
Response.Redirect vs Server.Transfer

Response.Redirect can be used for both .aspx and html pages whereas Server.Transfer can be used only for .aspx pages.
Response.Redirect can be used to redirect a user to an external websites. Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.
Response.Redirect changes the url in the browser. So they can be bookmarked. Whereas Server.Transfer retains the original url in the browser. It just replaces the contents of the previous page with the new one.

Monday, October 22, 2007

Bind data directly from database to gridview:::::: <_%_#_eval_(_"productname"_)_%_>

Major differences bw gridview and data grid:::::::::::

http://msdn.microsoft.com/msdnmag/issues/04/08/GridView/

Another key difference between the DataGrid and GridView controls lies in the adaptive user
interface. Unlike the version 1.x DataGrid, the GridView can render on mobile devices, too. In other words, to build reports on mobile devices, you can use the same grid control you would use for desktop pages. The DataGrid in version 2.0 can also render adaptively, but its UI capabilities are not quite as rich as those of the GridView
To deploy a com component and use it in .net::::::::::::

can use type library importer to convert a com dll to .net dll
or
blindly give a reference of com component in the com tab section in add references and start using it as if a normal .net dll.
RCW -- Runtime callable wrapper class acts here and performs as if its a .net dll

Wannna share a dll across applications?? :::::::::::
goto .net cmd
sn.exe -k
include the file name in assembly info assemblykeyfile("whole filename path") build the project.
copy the dll and put it in gac
Online C# to VB.NET code converter:::::::::::::
http://www.eggheadcafe.com/articles/cstovbweb/converter.aspx

There an expression repository at this link:::::::::::
http://www.regexlib.com/

.net faqs: ::::::::::
http://www.andymcm.com/dotnetfaq.htm#1.1

Awesome site on .net faqs::::::::::::::
http://www.dotnetinterviewfaqs.com/
http://www.techinterviews.com/?p=316#more-316
Choosing a Page Model::::::::::::::::::

The single-file and code-behind page models are functionally the same. At run time, the models execute the same way, and there is no performance difference between them. Choosing a page model therefore depends on other factors, such as how you want to organize the code in your application, whether it is important to separate page design from coding, and so on.

Advantages of Single-File Pages
As a rule, the single-file model is suitable for pages in which the code consists primarily of event handlers for the controls on the page.

Advantages of the single-file page model include the following:
In pages where there is not very much code, the convenience of keeping the code and markup in the same file can outweigh other advantages of the code-behind model. For example, it can be easier to study a single-file page because you can see the code and the markup in one place.


Pages written using the single-file model are slightly easier to deploy or to send to another programmer because there is only one file.

Because there is no dependency between files, a single-file page is easier to rename.

Managing files in a source code control system is slightly easier, because the page is self-contained in a single file.

Advantages of Code-Behind PagesCode-behind pages offer advantages that make them suitable for Web applications with significant code or in which multiple developers are creating a Web site.

Advantages of the code-behind model include the following:

Code-behind pages offer a clean separation of the markup (user interface) and code. It is practical to have a designer working on the markup while a programmer writes code.

Code is not exposed to page designers or others who are working only with the page markup.

Code can be reused for multiple pages.

Compilation and Deployment
Compilation and deployment of both single-file and code-behind pages is similar. At its simplest, you copy the page to the target server. If you are working with code-behind pages, you copy both the .aspx page and the code file. When the page is first requested, ASP.NET compiles the page and runs it. Note that in both scenarios you deploy source code with the markup.

Alternatively, you can precompile your Web site. In that case, ASP.NET produces object code for your pages that you can copy to the target server. Precompilation works for both single-file and code-behind models, and the output is the same for both models.
Managing ASP.NET Navigation:::::::::::::::::: http://www.ondotnet.com/pub/a/dotnet/2003/04/07/aspnetnav.html
Differences between Server.Transfer and Response.Redirect::::::::::::::::::::::

Redirect and Transfer both cause a new page to be processed. But the interaction between the client (web browser) and server (ASP.NET) is different in each situation.

Redirect: A redirect is just a suggestion – it’s like saying to the client “Hey, you might want to look at this”. All you tell the client is the new URL to look at, and if they comply, they do a second request for the new URL.
If you want to pass state from the source page to the new page, you have to pass it either on the URL (such as a database key, or message string), or you can store it in the Session object (caveat: there may be more than one browser window, and they’ll all use the same session object).
Transfer: A transfer happens without the client knowing – it’s the equivalent of a client requesting one page, but being given another. As far as the client knows, they are still visiting the original URL.


Sharing state between pages is much easier using Server.Transfer – you can put values into the Context.Items dictionary, which is similar to Session and Application, except that it lasts only for the current request. (search for HttpContext in MSDN). The page receiving postback can process data, store values in the Context, and then Transfer to a page that uses the values.

Awesome Difference::::::::
Response.Redirect sends message to browser saying that the browser should request some other page so basically it means that:
1. Browser is on page default1.aspx on which there is a Response.Redirect("") command which means that the server sends response (message) to browser that browser should request some other page default2.aspx

2. Browser sends request to server in order to get this page default2.aspx
3. Server sends page default2.aspx to browser

Server.Transfer doesn't tell the browser to request page default2.aspx. It just sends page default2.aspx, so e.g., browser address bar still shows the original page's URL.

Roundtrip is the combination of a request being sent to the server and response being sent back to browser.

Request is the message that the browser sends to the server and Response is the message the server sends back to the browser.

refernece: http://weblogs.asp.net/rosherove/archive/2003/08/11/23550.aspx

Monday, August 20, 2007

FAQS on .net ::::::::::::::::::::::
1. http://www.aspnetfaq.com/default.aspx
2. http://www.techinterviews.com/
Server transfer :::::::::::: reduces 1 round trip

usually there will be object context which will be in bw client and server. Whenever a client requests for a page, it actually hits a object context which displays a blank page and internally client hits server which actually serves the page. But whenever server transfer is used, client context is totally removed hence, u can see the same page title @ the top but page will actually be redirected. Basically used to transfer to error pages

Case scenario::::::::::::::::::::::::::: whenever u wanna call a page which is outside ur website, never use server.transfer.

Request: humbly asking
Response: expecting a reply
Server.Transfer : we are sure its there and asking ;)
State management

basically 2 types
1. Client state management --------- Cookies, Cache, Request
2. server side state management ------- Cache, Session, Application

NOTE:
Basic Differeneces bw cookies and cache is that Cache can be used to save the whole page or part of the page. But, cookies used to hold only few values
Application vs Session level variables

Session is for single user state management Applicaton is for multiple users state management
Best example for application variable is stock exchange value maintained and simple one is for hit rate
All about IIS 5 vs IIS 6.0

http://www.microsoft.com/technet/prodtechnol/windowsserver2003/technologies/webapp/iis/iis6perf.mspx

pretty simple one 2 explain the differences:

http://msdn2.microsoft.com/en-us/library/ms524539.aspx
add 2 column values of a datatable 2 datavaluefield of a dropdown list

DVU_eventsTableAdapter _events = _new _DVU_eventsTableAdapter();

_DataTable _dt = _events._GetData();
_for (_int _i = _0; _i < _dt._Rows._Count; _i++)
{
_DateTime _eventdate = _new _DateTime();
_eventdate = _Convert._ToDateTime(_dt._Rows[i]["event_date"]._ToString());
_string _formatted_date = _String._Format("{0:d}", eventdate);
_ddlEvent._Items._Add(_new _ListItem(_dt._Rows[i]["loc_city"]._ToString() + ", " + _dt._Rows[i]["loc_state"]._ToString() + " (" + _formatted_date + ")", _dt._Rows[i]["event_id"]._ToString()));
}

Reference::::: http://forums.asp.net/p/1088821/1627029.aspx#1627029
All about Design Patterns in .net

http://www.dofactory.com/Patterns/Patterns.aspx
Wannna have radio button inside grid view:::::::::::::::::: shud use name instead of id for a html radio button type

refernce: http://www.gridviewguy.com/ArticleDetails.aspx?articleID=149
To have check all option (alernate method) using javascript

<_pre _lang="_jscript"><_script _language="_javascript">_function _SelectAllCheckboxes(_spanChk){ _// Added as ASPX uses SPAN for checkbox _var oItem = spanChk.children; _var _theBox= _(spanChk.type=="checkbox") ?spanChk : spanChk.children.item[0]; _xState=_theBox.checked; _elm=_theBox.form.elements; _for(_i=0;_i<_elm._length;_i++_) _type="=" checked="_xState;">

reference: http://www.codeproject.com/aspnet/SelChkboxesDataGridView.asp
NOTE on Enabling visibility of a row in Gridview using javascript

If u make any rows invisible in grid view, u cant read the same rows in javascript, so instead of making it invisible, just use the following attribute

row.Attributes.Add("Style","display:none")

GridView Vs DataGrid

As long as control builders properly partition their state into behavioral state (to maintain core
functionality) and UI state (to retain contents), this statement should be followed religiously. I
would like to tell you to start following this recommendation now with all work done in ASP.NET 2.0, but the DataGrid has not been refactored to keep its behavioral state in control state. Fortunately, the new GridView is the logical successor to the DataGrid and it uses control state properly, as do the new versions of the TextBox and DropDownList controls.
Control State vs View State

When you are deciding what should go into control state and what should go into view state, remember that it should be a separation of behavioral state from content or UI state. Things like properties and collections of data should generally stay in view state and not migrate to control state. State that triggers a server-side event is the most typical type to store in control state.
Declarative Data Sources and View State
In simple case, if we have not disabled view state on the GridView, you may think that we are again just wasting view state on storing data that is never used. Fortunately, the ASP.NET 2.0 engine makes the extra effort to do the right thing here, and it will not bother going back to the database when view state is enabled on a control.

Similarly, if you disable view state on the GridView, the data binding to the data source will occur on each request including POST back requests.
This functionality is built into the DataBoundControl base class from which the AdRotator, BulletedList, CheckBoxList, DropDownList, ListBox, RadioButtonList, GridView, DetailsView, and FormView controls inherit. All of these controls exhibit this intelligent use of view state when bound to declarative data sources.

Reference : http://msdn.microsoft.com/msdnmag/issues/04/10/ViewState/
All about Control State

I mentioned earlier that one of the most frustrating aspects of working with server-side controls in ASP.NET 1.x is the all-or-nothing mentality with respect to view state. Behavioral aspects of controls like pagination in the DataGrid or selection change notifications in textboxes require view state to be enabled to function properly. I'm sure all of you are sufficiently daunted by the prospect of leaving view state enabled in any of your DataGrids at this point.
In ASP.NET 2.0, Microsoft addresses this particular problem by partitioning the view state into two separate and distinct categories: view state and control state.

Control state is another type of hidden state reserved exclusively for controls to maintain their core behavioral functionality, whereas view state only contains state to maintain the control's contents (UI). Technically, control state is stored in the same hidden field as view state (being just another leaf node at the end of the view state hierarchy), but if you disable view state on a particular control, or on an entire page, the control state is still propagated. The nice aspect of this implementation is that we can now amend our original principle on optimizing view state for ASP.NET 2.0 to be much stronger: if you populate the contents of a control every time a page is requested, you should disable view state for that control.

NOTE for Control State Users

For those of you building controls, the usage model for control state is not quite as convenient as view state. Instead of providing a state-bag with an indexer to insert and remove items, you must override the virtual LoadControlState and SaveControlState methods and manually manage your portion of the object collection that is mapped into control state. The one other thing you must do is call the Page.RegisterRequiresControlState method during initialization so that the page knows to ask for control state at the right time.
It is probably a good thing that storing items in control state is more difficult than view state since there is no way for users to disable it (there are also performance advantages to having an opt-in model for control state). Developers should think carefully before storing any state there as it will always be added to the rendering of a page.
View State improvements, pros and cons ;)

Advantage of ViewState:
There is one important place where view state is used, and that is in controls that issue server-side change events. If the user changes the value in a textbox or switches the selected element in a dropdown list, you can register an event handler and have code execute when the event is raised. These controls compare the current value of the control with its previous value, which is stored implicitly in view state if any process has subscribed to the change event. If you disable view state on a control whose change notification event you are handling, it won't fire correctly since it must always assume that the previous value was the same as the default value in the form.

View State Problems in 1.1:
As described earlier, the dropdown list and the textbox controls use view state to store the previous value to properly issue a change notification event on the server.
Similarly, the DataGrid class uses view state to issue pagination, edit, and sorting events.
Unfortunately, if you want to use features like sorting, paging, or editing in the DataGrid, you
cannot disable its view state.
This all-or-nothing mentality of server-side controls with respect to view state is one of the most frustrating aspects of the server-side control model in ASP.NET 1.x for developers who are trying to build fast, efficient sites.

View State Improvements in ASP.NET 2.0

The first one is the overall size of view state when it is serialized. In ASP.NET 1.x the
serialization of two strings into the view state buffer looks like this:
<_p<_l<_string1;>;_l<_string2;>>;>; [Plz ignore _]

The serialization format used in ASP.NET 1.x for view state is a tuple format consisting of a
hierarchical collection of triplets and pairs serialized using less-than and greater-than
characters
. The letter preceding the greater-than symbol indicates the type of the object stored (t=triplet, p=pair, i=integer, l=ArrayList, and so on). Each subelement within the less-than and
greater-than characters is separated with a semicolon. It's an interesting serialization format,
sort of like a compressed XML
. If you're concerned with space, however, it is not the most efficient serialization format (only marginally better than XML).

ASP.NET 2.0 changes this serialization format. The serialization of the same two strings into the view state buffer in ASP.NET 2.0 is shown in the following line of code:

[][]string1[]string2

At least that's what it looks like when rendered to a browser. The square boxes are actually
nonprintable characters which, if we rewrite using Unicode character references, turn into the code shown here:
string1string2

Instead of using a collection of printable characters to delineate objects in the view state stream ('<', '>', ';', 'l', 'i', 'p' and so on), ASP.NET 2.0 uses a number of nonprintable characters to
mark the beginning of an object and to describe what type of object it is.


.net 2.0 viewstate advantages
Using nonprintable characters to delineate the objects stored in view state serves two purposes.
First, it improves the efficiency of the lexical analysis during the parsing of the view state
string since there is no longer any need to match characters or parse tokens
.

Second, and more importantly, it reduces the number of characters used to encode the objects in view state. In my simple example of encoding two strings, the first encoding used 16 delineation characters versus 3 in the 2.0 format. This effect quickly compounds to make a significant impact.
aspnet worker process

http://msdn2.microsoft.com/en-us/library/ms225480(VS.80).aspx
All jingle bengle abt IE7 tabbing issues

After some searchs, i have found somebody else have this problem where he must maintain unique sessions between different Explorer tabs but have found the only way to do it is with cookieless sessions.

The reason this problem has come about is because the website is used to administer customer accounts. If I access CustomerA's account through the website then open a new tab and access CustomerB's account the session holding the customer ID updates to think I'm now working on CustomerB. Then if I click back to CustomerA's tab and start editing that page I am in fact editing the database record for CustomerB. This has happened and caused all sorts of problems so I need to find a fool proof way of stopping it. I don't want to put the customer ID in the URL as this will make it open to abuse.

So, what I did was to use cookieless sessions by putting sessionState mode="InProc"
cookieless="UseUri"
in the web.config. That way each tab generates a new unique session ID in the URL with the format like this :http://www.domain.com/(S(kbusd155dhzflbur53vafs45))/default.aspx
I hope the above information will be helpful. If you have any issues or concerns, please let me
know. It's my pleasure to be of assistance It is ugly but works however I've now realised that search engines bots will not index pages with session id's in the URL which is bad news.

Reference: http://forums.asp.net/t/1121933.aspx
All about viewstate and control state(st. from microsoft)

http://msdn.microsoft.com/msdnmag/issues/04/10/ViewState/

NOTE: when u put a break point @ some line of code and stop debugging, still the page would have executed successfully..............!!!!!!!!!!!!!!!!!!!!!!!!!!!
.NET Interview Questions / FAQs'

http://www.andymcm.com/dotnetfaq.htm#1.1
http://www.dotnetinterviewfaqs.com/
http://www.techinterviews.com/?p=316#more-316

Tuesday, July 03, 2007

TO rotate all the images in a webpage: here is a simple javascript

_javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; _DI=_document.images; _DIL=_DI.length; _function A(){_for(_i=0; _i
Link/Refer Javascript file in aspx page

Atlast i got the solution........, i am suppose to include the file in script tag inside form. This
is pretty interesting. Same wont work if its inside header tag.
This can also be added b4 html tag, the problem is, addin it there shall change the whole formatting of the page.

<_form id="form1" runat="server">
<_script src="JavaScript/CommonValidation.js" type="text/javascript">

References
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=418083&SiteID=1
http://forums.asp.net/t/908248.aspx
Regular Expression for dd-MMM-yyyy format for validator in asp.net 2.0

ValidationExpression="^([012]?\d3[01])-([Jj][Aa][Nn][Ff][Ee][bB][Mm][Aa][Rr][Aa][Pp][Rr][Mm][Aa][Yy][Jj][Uu][Nn][Jj][u]l[aA][Uu][gG][Ss][eE][pP][oO][Cc][tT][Nn][oO][Vv][Dd][Ee][Cc])-(1920)\d\d$"

Same can be incorporated in javascript

_function _checkISValidDate(checkobject)
{
_var -strRegs = _new
_RegExp("^([012]?\\d3[01])-([Jj][Aa][Nn][Ff][Ee][bB][Mm][Aa][Rr][Aa][Pp][Rr][Mm][Aa][Yy][Jj][Uu][Nn][Jj][u]l[aA][Uu][gG][Ss][eE][pP][oO][Cc][tT][Nn][oO][Vv][Dd][Ee][Cc])-(1920)\\d\\d$");
_if(!_checkobject.value.match(_strRegs))
{
_alert("Enter Date in dd-MMM-yyyy format");
_checkobject.focus();
_return false;
}
}

About javascript reguar expressions:
http://www.regular-expressions.info/javascriptexample.html
Note About Cookiessssssssssssssssss

1. Now Cookies will not be persisted to disk, only stored in memory during Safari's lifetime. You close Safari, Cookies go away!
2. IE and firefox works fine. They persist cookies to the client's disk, unlike safari.
Embedding style sheet while auto generating Emails

http://www.builderau.com.au/program/html/soa/Developing-an-HTML-formatted-mail-message/0,339028420,339275265,00.htm
Hudugaatada dialogues antare....., aadre naanu ee moviena nodidini, devranegu ee dialoguesgalu illa adralli[:(]
Addru, chennagive omme odi nodi.

Love Maadu, aadre Life miss Maadkobeda..
Feel Aagu, but Future halu Maadkobeda..
Think maadu, but Time waste Maadkobeda..
Aaata aadu, aadre.. "HUDUGAATA " aadabeda...


Sakkath majappa life andre,
dodda paata kalside lifeu,
talent ide, use illa,
buddi ide, dudd illa,
chennagidini, smart aagilla,
awnajji, naanu sattu, heege mele hodmele, awnge ondu gati kaansteeni nodtaa iri
alli mele kutkondu aata aadtaane, HUDUGAATA...


2007 Lovers Bhavishya:
Lovalli, Huduga Deep aadre-"MUNGAARU MALE"
Hudugi Deep aadre, "DUNIYA"
Huduga Hudugi ibrru Deep aadre, ade " HUDUGAATA "
DataView Sorting, Filtering and DataBinding in ADO.NET 2.0

Converting DataView to Table - ADO.NET Tutorials : http://davidhayden.com/blog/dave/archive/2006/02/11/2798.aspx

if (strTripType.Equals("BV"))
{
dvFTRList = new DataView(dtFTRList, "TVISA = 'BV' or TVISA = 'B1'", "TVISA", DataViewRowState.CurrentRows);
}
else
{
dvFTRList = new DataView(dtFTRList, "TVISA <> 'BV' and TVISA <> 'B1'", "TVISA", DataViewRowState.CurrentRows);
}
Incorporate Refresh option with a button click(Obviously javascript)

1. Copy the coding into the BODY of your HTML document

<_body>
<_div align="center">
<_script language="JavaScript">

_document.write('<_form><_input type="button" value="Refresh" onclick="history.go()">')
<_p><_center><_font style="font-family:arial, helvetica;">Free JavaScripts provided<_br>by <_a href="">the/'>http://javascriptsource.com">The JavaScript Source<_p>
Merge 2 DataTable

check out this: http://codebetter.com/blogs/john.papa/archive/2005/03/30/ADO-NET-2-DataTable-Merge.aspx
Binding 2 Drop Downs in a grid view???

whenever u have 2 drop downs in a gridview and wanna bind one drop down due 2 post back of otheruse this
protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
{
string foundID = String.Empty;
GridViewRow row = (GridViewRow)((sender) as Control).NamingContainer;
// get the value from the first dropdownlist
DropDownList ddlFirst = ((sender) as DropDownList);
int ddlFirstSelectedValue = Convert.ToInt32(ddlFirst.SelectedValue);
string firstDropDownListID = ddlFirst.UniqueID;
// and now here is how
DropDownList ddlSecond = row.FindControl("ddl2") as DropDownList;
// now from here you can do whatever you want!
}
Convert Date String to DateTime Object??

You could use the DateTime.ParseExact() method to convert the date string into a DateTime instance:

Format SAP DateTime String to dd-MMM-yyyy?
string sapDate = ...
DateTime date = DateTime.ParseExact(sapDate, "yyyyMMdd", new System.Globalization.DateTimeFormatInfo());
string myString = date.ToString("MM/dd/yyyy");

Afterwards, use DateTime.ToString() method to convert it back to a string in the format you need.
Datatable Sorting?????

Check this out http://davidhayden.com/blog/dave/archive/2006/02/11/2798.aspx
tilde (~) problem in live server

If someone should experience the same problem, I've found the solution.

The behaviour happens if you use wildcard mapping in IIS and the default page for the root folder of the application inherits from a custom Page type.

Here are workarounds:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105061
and here the ms patch
http://support.microsoft.com/?scid=kb%3Ben-us%3B911300&x=11&y=10
Add New Row to a Grid View

Adding new row to a grid view, offcourse with a post back is pretty simple. All u have to have is atlas tool installed, ie ajax extender tool installed.
Drag a Update panel from ajax tool kit and drop ur grid view on the same. Update panel feature is that, post back shall happen with only the panel controls and seems like there was actually no post back at all.

Code below is the example which clearly explains update panel :)

ASPX page
<_body>
<_form id="form1" runat="server">
<_asp:scriptmanager id="ScriptManager2" runat="server">
<_asp:updatepanel runat="server" id="UpdatePanel1" updatemode="Conditional"> <_contenttemplate>
<_div style="background-color: Lime; width: 100px;">
<_asp:label id="PartialPostBackLabel" runat="server">
<_asp:button id="PartialPostBackButton" runat="server" text="Partial Post Back" onclick="PartialPostBackButton_OnClick">

<_asp:gridview id="grdvShortTermFTRs" runat="server" autogeneratecolumns="False" pagesize="5" showfooter="True">
<_columns>
<_asp:hyperlinkfield headertext="FTR No." text="Testing" datatextfield="test1" datanavigateurlfields="test1" datanavigateurlformatstring="~/Default.aspx?FTRNo={0}">
<_itemstyle width="75px">

<_asp:boundfield headertext="Employee No." datafield="test2"> <_itemstyle width="75px">

<_asp:boundfield headertext="Name" datafield="test3">
<_itemstyle width="125px"> <_asp:boundfield headertext="Country" datafield="test4">
<_itemstyle width="75px">


Code Behind
public partial class Default2 : System.Web.UI.Page
{
public static int intRowCount;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ intRowCount = 3; bindGridView();
}
}
protected void bindGridView()
{
DataTable dt = new DataTable();
DataColumn testcolumn1 = new DataColumn("test1");
DataColumn testcolumn2 = new DataColumn("test2");
DataColumn testcolumn3 = new DataColumn("test3");
DataColumn testcolumn4 = new DataColumn("test4");

dt.Columns.Add(testcolumn1); dt.Columns.Add(testcolumn2); dt.Columns.Add(testcolumn3); dt.Columns.Add(testcolumn4);
for (int i = 0; i < intRowCount; i++)
{
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
}
grdvShortTermFTRs.DataSource = dt;
grdvShortTermFTRs.DataBind();
}
protected void PartialPostBackButton_OnClick(object sender, EventArgs e)
{
intRowCount++; bindGridView();
}
}
All about new features introduced in C# 2.0 and .NEt 2.0

Reference: http://www.codeproject.com/books/net2_cs2_newfeatures.asp

Wednesday, May 30, 2007

DENGAARU MOLEY!!!!!!!!!!!!!!!!!!!!!!

Devaranegu heltini...., "Mungaaru Male" na naanu 3 saari nodidagalu intha olle remix aitade adondu dialogueu antha andkondirodirli, adra sulivu irlilla nanage. Aadre ,nenne taane idanna nodide kanri...., satttogo astu nagu bandbidtu. Probably, nandu gatti jeeva adakke saaililla, adu secondary.
Idanne blognalli haakona antha haakta idini...., nothing offending plzzzzzzz :)

"Nivu nan kaili keyskondilla antha nange bejarilla kanri. Nim Thika, Nim Thode, Nim Sonta, Nivu baggidaaga nodida aa moley saaku kanri. Adanne rewind maadi maadi jatka hodkondu nan life na thalli bidthini kanri. Adre ondu vishya thilkolri nimma aa nagna deha nenskondu naanu jatka hodkolvastu bere yaaru hodkolalla kanri. Nan thunne murdogli, kithkond kai ge barli, naan satthru jatka hodkolthane irthini kanri!!!! [:D] "

Monday, May 21, 2007

All about "HEALTH MONITORING" in asp.net 2.0

Check this......., vvvvvv important concept

http://msdn2.microsoft.com/en-us/library/ms998306.aspx
Adding popup calendars in a aspx page

here is a good sample to pop up a server calendar control rather than use any javascript calendar control
http://www.15seconds.com/issue/040315.htm

if you want to use javascript calendar.. than check out this cool skinned calendar (dhtml) which can be used...
http://www.dynarch.com/projects/calendar/

There is a Calendar control in AJAX tool kit, it is a perfect one.
How Do I: Configure the ASP.NET AJAX Calendar Control?
To change button text as "page loading" once button is clicked :)

Execute the below code in page_load event


_System.Text.StringBuilder sbValid = _new _System.Text.StringBuilder();
sbValid.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sbValid.Append("if (Page_ClientValidate() == false) { return false; }} ");
sbValid.Append("this.value = 'Please wait...';");
sbValid.Append("this.disabled = true;");
sbValid.Append("document.all.btnSubmit.disabled = true;");
//GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.
sbValid.Append(this.Page.GetPostBackEventReference(this.btnSubmit));
sbValid.Append(";");
_this.btnSubmit.Attributes.Add("onclick", sbValid.ToString());

Where btnSubmit is a simple asp button

I need to read Html source of a Web From at Server -- Copy the whole html source code before actually rendering it

<%@ _Page Language="C#" _AutoEventWireup="true" _CodeFile="RenderPageToHtml.aspx.cs" _Inherits="RenderPageToHtml" _Trace="true" %>

<_head runat="server"> <_title>Untitled Page<_body>

<_form id="form1" _runat="server"> <_div> <_asp:_textbox id="TextBox1" runat="server" height="414px" textmode="MultiLine" width="198px"> <_asp:_button id="Button1" runat="server" text="Button"> <_asp:_linkbutton id="LinkButton1" runat="server">LinkButton using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class RenderPageToHtml : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Session["text"] != null) { TextBox1.Text = Session["text"].ToString(); } } protected override void Render(HtmlTextWriter writer) { System.IO.MemoryStream mem = new System.IO.MemoryStream(); System.IO.StreamWriter twr = new System.IO.StreamWriter(mem); System.Web.UI.HtmlTextWriter myWriter = new HtmlTextWriter(twr); base.Render(myWriter);
myWriter.Flush(); myWriter.Dispose();
System.IO.StreamReader strmRdr = new System.IO.StreamReader(mem); strmRdr.BaseStream.Position = 0; string pageContent = strmRdr.ReadToEnd(); strmRdr.Dispose(); mem.Dispose(); Session["text"] = pageContent; writer.Write(pageContent); }}

Reference: http://forums.asp.net/t/1112091.aspx

How to convert excel and csv file into xml in asp.net....

Hi,
To convert excel to XML see:
http://www.codeproject.com/office/excel2xml.asp
To convert CSV to XML see:
http://blogs.msdn.com/kaevans/archive/2003/04/17/5780.aspx
(It is not writed via ASP.NET, but you can refer it.)
To convert excel to csv see:
http://www.devasp.net/net/articles/display/141.html
Another way to insert data into database

string Name = _TextBox1.Text;
string Surname = _TextBox2.Text;
SqlDataSource userQuizDataSource = new SqlDataSource(); userQuizDataSource.ConnectionString =
ConfigurationManager.ConnectionStrings["Demo_DBConnection"].ToString(); userQuizDataSource.InsertCommand = "INSERT INTO [Student] ([Name], [Surname]) VALUES (@Name,@Surname)";

userQuizDataSource.InsertParameters.Add("Name", Name); userQuizDataSource.InsertParameters.Add("Surname", Surname); userQuizDataSource.Insert();