Reading and Writing XML File

By admin - Last updated: Tuesday, March 23, 2010

XML is an extensible markup language

XML is a text-based markup language that is fast becoming the standard for data interchange on the Web. HTML emphasis on presetation of data and XML emphasis on the Data itself. Like HTML, you identify data using tags (identifiers enclosed in angle brackets: (<…>). Collectively, the tags are known as markup. Each starting tag must have a closing tab. This is case sensitive, the opening and closing tags must match exactly and the data will come between the opening and the closing tags.

<sample> data </sample>

If there is no data i.e. empty tag then you can also write it as

<sample/>

if you are writing

<sample>

<data>this is data</data>

</sample>

this can also be written as

<sample data=”this is data”/>

where data is called an attribute and its values must be enclosed in inverted commas.

<!– This is a comment –>

sample xml file

<?xml version=’1.0′ encoding=’utf-8′?>

<!– A SAMPLE set of slides –>

<slideshow>

<title>c#</title>

<author>ajay</author>

<address>

<doorno>123</doorno>

<street>23</street>

</address>

<noofslides>1</noofslides>

</slideshow>

can also be written as

<?xml version=’1.0′ encoding=’utf-8′?>

<!– A SAMPLE set of slides –>

<slideshow title=”c#” author=”ajay” noofslides=”1″/>

You can use the dataset object to directly read or write xml files.

once the dataset has tables and data in it just call its writexml or writexmlschema method giving the name of the file to be created.

this will generate the xml/xmlschema automatically.

if you are having xml file then you can display its contents using dataset. call the dataset’s readxml method with the filename as the xmlfilename to be read.

Filed in ASP.NET • Tags: , , , , ,

New features of .NET 2 compared to .NET 1

By admin - Last updated: Tuesday, March 23, 2010

There are several new language features in framework2. Some this are very usefull.

These are the main language specific features. Let us examine other features that are new ASP.NET2.

What are the new features of Framework 3 comapared to earlier framework?

Filed in Uncategorized • Tags:

What is difference of .net 3 Framework?

By admin - Last updated: Tuesday, March 23, 2010

Essentials of Framework 1 and 2

NET Framework 3.0 is somewhat different from the 1.x and 2.0 .NET Framework. The first two .Net frameworks focused on allowing many different languages to communicate with a common set of libraries translated through the Common Language Runtime (CLR). Introduced with .NET 1.1 and enhanced with .NET 2.0, the CLR works on a relatively simple concept: A common runtime model executes code for any system running the .NET Framework. What this means to you as a developer is that you don’t need to keep relearning languages for different technologies. For instance, a C# developer who writes Windows Forms applications take the knowledge used for building forms and apply it to writing web pages. Similarly, a Visual Basic .NET developer can switch from writing mobile applications to writing web services. The CLR acts as an arbitrator and communicates back and forth.

.net Framework 3

The .NET 3.0 Framework is not improving upon existing technologies but rather introducing four new foundation technologies:

Each of these technologies is a new cornerstone that developers can leverage for new solutions.

Framework 3.5

.NET Framework 3.5 builds incrementally on the new features added in .NET Framework 3.0. For example, feature sets in Windows Workflow Foundation (WF), Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF) and Windows CardSpace. In addition, .NET Framework 3.5 contains a number of new features in several technology areas which have been added as new assemblies to avoid breaking changes. They include the following:

Filed in ASP.NET • Tags:

.NET Framework History

By admin - Last updated: Tuesday, March 23, 2010

MS.NET 1.1 : 2003

MS.NET 2.0 : 2005

Filed in ASP.NET • Tags: , , , , ,

Caching in ASP.net with examples

By admin - Last updated: Tuesday, March 23, 2010

Caching is used to inprove the performance of our application.

normally caching is enabled on the pages which are requested a lot and for which some cached responce can be given. you can control how long the cached responce should be valid and after the time out the cache page should be removed.

There are three types of caching

Page caching

to enable page caching add the following tag in the html view of the page

<%@ OutputCache Duration=”50″ VaryByParam=”None” %>

sometimes the same page will be asked with varying parameters say list of employees belonging to a particular department

for this use the vary by param attribute of the output cache directive

try giving deptno in varybyparam attribute and then when checking the page in browser attach ?deptno = 1 to the url and check

later change it to deptno = 2

you will get various versions of the same page depending on the deptno, each version valid for 50 seconds from the time of its creation.

Fragment caching

create a user control and enable output caching for that control. when this control is placed on a page contents of this control will be comming from cache where as the remaining page will be refreshed so here as only some part of the page is comming from cache it is called fragment cache.

for crating user control, in the solution explorer right click and add new item select web user control and click add.

drag a lable contorl on it and in the source view i.e. html view type the output cache directive

<%@ OutputCache Duration=”50″ VaryByParam=”None” %>

in the load event of the control type the code

label1.Text =DateTime.Now.TimeOfDay.ToString();

now on any page this control is used this will be served from the cache for 50 secs.

Data Caching

Cache["Key"] = value;

cache["name"] = “Hello”;

string st = (string)Cache["name"];

cache["age"] = 10;

int age = (int)Cache["age"];

you can attach the time of expiration and dependencies to data caching

Filed in ASP.NET • Tags: , , , , , , , ,