RSS Feeds
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Saturday, May 15, 2010

ViewState Control in ASP.NET 4.0


View State is one of the most important and useful client side state management mechanisms. It can store the page value at the time of post back (Sending and Receiving information from Server) of your page. ASP.NET pages provide the View State property as a built-in structure for automatically storing values between multiple requests for the same page.

we generally used “EnableViewState” Properties for both Page Level and Server Control Level to maintain the view state. Till ASP.NET 3.5 Version, Page Level view state control treat as highest priorities. Which means If we set EnableViewState= “False” in page level that will automatically derived by all the server side control. In that case if we set “EnableViewState=”True”” for any server side control will treat as false, as we have defined them “False” in Page Level.Here is one complete article on ASP.NET 2.0/3.5 View State , which may helpful for you

Now, let’s have a look into the changes in ViewState Control in ASP.NET 4.0. There is a massive change in View State Control in ASP.NET 4.0 which is very much helpful for developer also. Asp.net 4.0 added a new property to Page object and server controls called ViewStateMode.

Sunday, January 10, 2010

My New Article : Exploring Caching : Using Caching Application Enterprise Library 4.1

Enterprise Library caching application Block provides ready to use Caching Framework. This  can be used in various application like

* ASP.NET Web application
* Windows Forms
* Console
* Windows Service
* Enterprise Services
* Web service
Implementing caching using Caching Application Block improve the performance of application as well as reduces the development time and cost. This Application blocks provides all kinds of function like adding, removing, managing expiration of cache.
As caching application block is predefined set of code and that are defined in a framework for that we need install Enterprise Library 4.1 First then we need  to add some reference in to our application. These are Microsoft.Practices.EnterpriseLibrary.Caching.dll and Microsoft.Practices.EnterpriseLibrary.common.dll.

I have published one complete article on Codeproject.com which describe how to use Enterprise Caching Application Block 4.1 . Here is my complete article
Exploring Caching : Using Caching Application Enterprise Library 4.1

Please provide your valuable suggestion and feedback to improve my articles.

Thank you !

Saturday, September 26, 2009

My New Article : DotNetNuke : User Creation and Role Assignment : For Absolute Beginners!

Today, I have published another article on DotNetNuke (DNN). I am working with DNN for last 1 year and having a good experience on DNN. This article is about to create user and roles in DNN. This will really helpful to all the DNN Beginners. If you really interested, Here is my complete article DotNetNuke: User Creation and Role Assignment : For Absolute Beginners!
Please provide your feedback and suggestion for improve this article. Thanks

Saturday, August 8, 2009

My New Article : Test Your ASP.NET WebServices using SOAP UI

Today I have published another article on Web Service Testing- Using SOAP UI.  This is very important to test our web service before we moved it to production. Soap UI is one of the best tool for test any SOAP Request and Response. If have described the basick overview of that tool so that any one can start from scratch. If you are really intereseted, then please read my article complete  here, Test You Web Service Using Soap UI

Please give your suggestion and feedback .

Wednesday, July 15, 2009

My New Article : Debug your web application Hosted on Remote IIS

Lastnight I have published another article on debugging of ASP.NET article which hosted on Remote IIS Server. Its all about the how to msvsmon.exe and its configuration. If you really interesed, Here is my complete article Remote IIS Debugging : Debug your ASP.NET Application which is hosted on "Remote IIS Server"
Please give your valuable suggestion and feedback.

Tuesday, July 7, 2009

XSL Transformation : Rendering XML using XSL - HTML Output

Overview

Some times we need to display the XML data in our web application in specific format. XSLT provides the ability to display the XML document in some specific format like HTML, PDF etc. We can select a a XML file or a portion of XML File and using XSL Transformation we can display in some specific format.

SampleFlow

An XSL transformation need an XML document to transform and an XSL style sheet describing how the transformation will take place. An XSLT engine then transforms the XML document via the XSL style sheet and will produce the output in the format specified by the style sheet.
Here I am just going to show you how we can display a XML data using XSL in our web page and which will help beginners to start with. This is an sample application. The XSL, which I have used over here is very simple. If you want to learn details on XSL please read tutorials from W3School.

 

 


How to Implement ?


1. Create Data Base :

Rather than reading the data from xml, I have read the data from database. First of all I have create an DB Student with table name "StudentDetails" . Table contain some dummy data like,

db

2. Add XSL File


Before, reading the data from database, we have to create the XSL file, We can add XSL file by just right click on the project > Add New Item >Select XSLT File


AddXSL




I have put the xsl file in a specific folder called XSL .

 

 



FileH

 

 

3. Desing XSL

Now, Designing XSL is one of the important task, and there are many things that related with XSL . In my case, this is very simple XSL, but if you need to learn in details, I will suggest you to read from W3School. First of all have a look into the XML data which I have got from the dataset.

xml

And based on that we need to desing the XSL File. Below is the StudentDetails XSL
 

 

[sourcecode language='xml']



style="background-color:#123456;font-family:verdana;font-size:10pt;border:1">






Roll

Name

Address


style="font-family:verdana;font-size:10pt;border:1">













[/sourcecode]

Now, have a look into the code,

Read the data from database and put it into dataset. We can easily get the XML from dataset using.

[sourcecode language='csharp']

string XMLString=ds.GetXml();

[/sourcecode]

Below code is used to read data from database

[sourcecode language='csharp']
public string strstudentDetails = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
string _strConnectionString = "Data Source=.\\sqlexpress;Initial Catalog=Student;Integrated Security=True";
string _strquery = "select * from studentDetails";
SqlConnection con = new SqlConnection(_strConnectionString);
DataSet ds = new DataSet("Students");
SqlDataAdapter da = new SqlDataAdapter(_strquery, con);
da.Fill(ds);
//Get the XML From DataSet
string strXML = ds.GetXml();
strstudentDetails=GetHtml(Server.MapPath("~/xsl/studentDetails.xsl"), strXML);
}
[/sourcecode]

GetHtml function actually doing the job. Its taking XSL Stylesheet and XML data as parameter and returning the html output

 

 


 

 

[sourcecode language='csharp']
///
/// Get HTML From XML and XSL
///

///
XSL File Path
///
XML String
/// HTML Output
public static string GetHtml(string xsltPath, string xml)
{
MemoryStream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xml));
XPathDocument document = new XPathDocument(stream);
StringWriter writer = new StringWriter();
XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(xsltPath);
transform.Transform(document, null, writer);
return writer.ToString();
}
}
[/sourcecode]

Now for displaying the result, we have to put following line in the aspx page,

[sourcecode language='html']


Student Page












Student Info : Displying using XSL Rendering

<%= strstudentDetails %>






[/sourcecode]

and the output like,

Output123

Hope this will help you to move ahead with XSL Transformation.

Thankyou
 

 
 

 

 

Thursday, June 11, 2009

My Recent Article :Debug Your ASP.NET Application that Hosted on IIS : Process Attach and Identify which process to attach

Ahh... After a long time, I have a published an article on Codeproject.
This article describe how to debug a web application which is hosted on IIS. It also describe how to select a particular process to attach with your application when multiple worker process are running. Please read details over here and give your suggestions and feedback

Thank you.

Tuesday, March 24, 2009

First Prize winner in Competition "Best ASP.NET article of January 2009"

I have won the first prize for my "Exploring Session in ASP.NET" article in the month of January . Thanks to all for voting.