Skip to main content

Posts

Showing posts from 2009

Implement Serverside ViewState

If you think your website is running slowly and you need to improve performance by 150% in short time . This may help you a lot. ASP.NET ViewState is a great mechanism that simplifies the life of ASP.NET developers. But, as everybody knows, the .NET Framework saves the ViewState data as a hidden field on your ASPX page. If your page has only a few controls, this is not a problem. But, if your page has some Panel s and/or some DataGrid s, with the technique demonstrated on this article, you could reduce dramatically the load time of the page.

Using IsInRole() with Forms Authentication

A Little background…. Page object provides User [ System.Security.Principal.IPrincipa l ] in order to access to the information about the current authenticated user. User is having following two important members. These members provide way to implement Role-based authorization programmatically. Identity [Property] [ System.Security.Principal.IPrincipal.Identity ] – This property provides important members like AuthenticationType, IsAuthenticated, Name. IsInRole [Method] [ System.Security.Principal . IPrincipa l ] – This method takes single parameter that is string value of Role for which to check the membership.

Basic Differences between Abstract class and Interface

 Behaviour Abstract Class Interface Multiple Inheritance Not Possible Possible Inheritance Chain(of same type) Possible Not Possible (does not fall under the inheritance chain of same type) Concrete Functionality Possible Not Possible Private Members Not Possible Possible Type can be declared as method input parameter Not Possible (because instance could not be created) Possible (acceptable with fully implemented instance is being passed) Structs can implement Not Possible Possible Every member needs to be implemented No Yes

Differences between Object Serialization and Deserialization?

Serialization = putting the relevant state of the object into a streamable representation. That can mean converting it to a byte stream. This does not necessarily include copying every member variable into the stream. Deserialization = restoring an object from a serial representation and ensuring the invariants of the object. Deserialization can be thought of a separate constructor for the object.

The ASP.NET Page Life Cycle

When a page request is sent to the Web server, whether through a submission or location change, the page is run through a series of events during its creation and disposal. When we try to build ASP.NET pages and this execution cycle is not taken into account, we can cause a lot of headaches for ourselves. However, when used and manipulated correctly, a page's execution cycle can be an effective and powerful tool. Many developers are realizing that understanding what happens and when it happens is crucial to effectively writing ASP.NET pages or user controls. So let's examine in detail the ten events of an ASP.NET page, from creation to disposal. We will also see how to tap into these events to implant our own custom code. I'll set the stage with a simple submission form written in ASP.NET with C#. The page is loaded for the first time and has several server-side Web controls on it. When the Web server receives a request for the page, it will process our Web controls and w

Comparing or fetching only date parts (without time) from datetime in SQL Server

The function Cast(Floor(Cast(GetDate() As Float)) As DateTime) returns a datetime datatype with the time portion removed and could be used as so. Select * Table1 Where  Cast(Floor(Cast(Column_DateTime As Float)) As DateTime) = '14-AUG-2008'        or DECLARE @p_date DATETIME SET @p_date = Cast('14 AUG 2008' as DateTime) SELECT * FROM table1 WHERE Cast(Floor(Cast(column_datetime As Float)) As DateTime) = @p_date

Script Callback

What is the difference between a callback and a postback? A callback is a special postback, so a round-trip always occurs; however, unlike the classic postback, the script callback doesn't redraw the whole page.  ViewState is not updated during a callback, it is for postback. How to make a callback? In the client side JavaScript code, if GetCallbackEventReference() method is reference, then when the JavaScript code is executed, a channel to the server is opened and an HTTP request is sent to the remote ASP.NET page.