Monday, July 9, 2012

ASP.Net Menu and Rendering Issue in IE8

If you have ever used ASP.Net built in menu with dynamic data binding, you might have encountered an odd rendering issue with IE8.Instead of displaying the sub menu items, it would be displaying empty white boxes. Strange, isnt it? J .I would become more odd when u realize this is not happening for static data binding.. You might have wondered How come it happens, IE8 being a Microsoft outcome.
How to Overcome?
Here is the root cause of the issue.IE8 returns Z-Index property as “auto” until unless we have explicitly  specified it as some other value.

1. Override Z-Index property

One of the possible workaround is to override the Z-Index property, so that the application would not return Z-Index as “auto” any more.

2. Render the Application in IE7 standards

You can also overcome the issue by applying IE7 Meta tag to the HTML. By applying IE7 Meta tag, which forces the application to render in IE7 standards. Cool ,Huhh? J

IE8 Rendering Issue fix

Friday, July 6, 2012

ASP.NET Page Life Cycle Events

When a page request is sent to the Web server, the page is run through a series of events during its creation and disposal. In this article, I will discuss in detail the ASP.NET page life cycle Events 

(1) PreInit
(6)Control (PostBack) event(s)

(1) PreInit

    This is the very first page event that gets fired when a request for a page occurs.We can say "PreInit" as the entry point to the Life cycle events.At this satge we can dynamically set the master page,  set their skin properties and can access the controls in the master page as well.
From  the code block ,we can see how the master page has been set at runtime and how i accessed the controls in the master page dynamically.If u try to set the master page in any othe page events it will though error.

(2) Init

  This event fires after each controls has been initialized,their UniqueId has been set and skin settings have been applied .This event gets fired in the revers heirarchy order ,ie starting from child control to the parent ones untill its fired for the page itself.
We can use this method to change the initilization values of the control.

(3) InitComplete
 This event is rised once initialization of all controls and page completed. From this state onwards the ViewState for server controls become accessible.

(4) PreLoad
    This is the first event where viewstate functionality starts retrieving their values.In this method, page will load values from viewstate.

     The page Load events executes after the Page_PreLoad event.By now the page has restored to its initial state in case of postback.Code inside the page load event typically checks for PostBack and then sets control properties appropriately. 

 (6)Control (PostBack) event(s)

   ASP.NET now calls any events on the page or its controls that caused the PostBack to occur. This might be a button’s click event or a dropdown's selectedindexchange event, for example.These are the events, the code for which is written in your code-behind class(.cs file). 



  This event signals the end of Load.We can use this event for the tasks which require all the controls in the page to be loaded.


  This event gets fired when page had loaded all the controls that user could see in his browser.This is the last event that could reflect any changes in the page ,that has to be shown in the browser.The PreRender event occurs for each controls in the page.


  Prior to this event ,ViewState have been loaded for page and for all the controls.Any changes to the page or controls at this stage will be ignored.We can use this event for tasks that require all ViewSate valuesto be saved,but that do not make any changes to the controls.

(10) Render

 The rendor method generates the client side HTML,DHTML and scripts that is required to render the output in the browser and to implement the client side functionalities.

(11) Unload

  This is the last event that gets fired.At this stage you can dispose any object and references that has been made to construct the page including the page object.