Friday, July 1, 2011

UpdateMode in Update Panel

UpdateMode property in Update Panel.

Why update panel is slow?
Due to Update Mode property of the UpdatePanel. If it is set to Always it will make the whole page slow. Since on each post back each Update Panel content update.

This property plays an important role in performance of ASP .Net page. By default it is Always.

When UpdateMode set to Always?

1) The update panel content is always updated on each post back of page whether it is synchronous call or asynchronous. No matter the control that triggered the post back is inside the update panel or not. Or inside other update panel.
2) If the update panel is inside other update panel. Than when parent will update child always update. No matter child update panel update mode is Always or Conditional.

When UpdateMode set to Conditional?

1) Update Panel content will update only in case of any control that is inside Trigger cause post back.

2) Or if ChildrenASTrigger set to true. Than Update Panel contents update in case of its child cause post back.

3)Or you have called Update method of Update Panel explicitly.

ChildrenAsTrigger property in UpdatePanel
Set it to true to update the content of update panel on post back cause by children control of the update panel. If panel is nested with another update panel. Than parent update panel contents will not update on post back cause by children control of the inner update panel.

By default value of ChildrenASTrigger is true.

You can not set it false with UpdateMode="Always". In that case InvalidOperation Exception thrown during PreRender event.

RenderMode property in UpdatePanel.

There are two possible values for RenderMode one is inline and other one is block. if it is set inline Update Panel convert into span tag. In case of block Update Panel convert into div tag. By default value of RenderMode is div.

No comments: