Thursday, May 8, 2008

Handle ClientSide onLoad in AJAX


See my earliar post on the same.

We oftenly handle the onLoad event in JS. But the moment we include AJAX (Script Manager) in our pages, the onLoad event fires only for the first time and then never. In such cases, we’ll end up with problems. For. E.g Hiding Label on Client load, will fail after the first load event .

To handle this, need is to introduce the load handler in AJAX, rather than the regular one. Here is the code.

<asp:ScriptManager ID="scmObjectAssignment" runat="server">


<script language="javascript" type="text/javascript">

var prm = Sys.WebForms.PageRequestManager.getInstance();


function pageLoaded(sender, args)


var element = window.document.getElementById('lblName');

if(element != null)

{ = ‘none’;




Thanks & Regards,

Arun Manglick || Senior Tech

No comments:

Post a Comment