Friday 17 April 2009

How to centre align a DIV tag?

It sounds like a very simple question but it is not for those who have worked more with TABLEs and not with DIVs. Of course, these tags are not specific to ASP.NET technology but its very essential to have knowledge about HTML tags while working on any web based applications, especially those which should support multiple browsers. 

Whether to use TABLE or DIV is a separate topic of discussion but many agree that DIV has edge over the TABLE although its little difficult to work with it.

So, the question is, How to centre align a div tag? The answer is:

Centerdiv-1 Looks simple right? but as you can observe there is no specific style tag related to alignment (you can use *align* but that will work only with specific browsers) and even putting alignment on body tags wont work for you.

You can go further and align the contents of the div to centre
by doing this:

Centerdiv-2I hope this info helps. I will try to write more about differences between table and div in my next post.

Tuesday 24 February 2009

View State Chunking

We all know that in ASP.NET, View State is the solution for persisting changes done to the Web Form across different page requests. It does this by using HTML hidden field and ASP.NET's integrated serialisation and de-serialisation mechanism. I am certain that Viewstate mechanism is a boon for those who have come from a background of classic ASP development.

Lets not put too much time in understanding what View State is and why its here. Lets see what View State chunking is..

Though a hidden field can store unlimited information, some proxy servers and firewalls restrict the pages to pass through if data in the hidden field is greater than certain size. For example, you have a gridview on your form and its showing massive amount of data with EnableViewState is set to true, then its likely to persist heavy information in hidden field. Such pages may suffer restrictions on certain proxy servers or firewalls. In such situation View State Chunking mechanism comes handy. It automatically divides the view state data across multiple hidden fields and makes sure that no hidden field surpasses the defined size.

We need to visit web.config file for achieving this.

<configuration>
<system.web>
<pages maxpagestatefieldlength = "2048">
</system.web>
</configuration>


Set the maxPageStateFieldLength attribute of the element in web.config file. The size is specified in bytes. In above example, the maximum amount of viewstate data allowed to be stored in single hidden field is 2KB. If view state information exceeds 2 KB then you can check in the HTML source that multiple view state hidden fields are emitted in the page.

As a good practice, try to keep as less data as possible in viewstate for better performance. So now we understood that View State chunking is a technique for avoiding problems that may created by certain proxies and firewalls.

I hope you will find this information helpful!

Wednesday 3 September 2008

The Reason

Hi,

I have been working as web developer since many years now and it has been really exciting journey till date. I started with Classic ASP and now working on ASP.NET 3.5. I must agree that experience of working with classic ASP (Working closely with HTML tags and Javascripts) helped me understand revolutionary ASP.NET better.

My intention behind creating this blog is to share my day-to-day notable experiences and eventually develop a knowledge base which I feel, may help ASP.NET developers.

I hope you will find my blog helpful!

Paresh