call javascript function after server side code is run

manared

Well-known member
Joined
Jun 1, 2006
Messages
84
Programming Experience
1-3
I'm using VS 2008 and Asp 3.5 with SQL.
I have a web application that I've created using master and content pages. I have a header in my master page that can be updated through a javascript funtion. For example, I have a cart page and when the grid is updated, it changes the header like this:

vb code in content page to call the javascript function

VB.NET:
grdCartItems.ClientSettings.ClientEvents.OnRequestEnd = "cartInfo('" & totalQty & "', '" & totalAmount & "')"


calls this javascript function in the master page


HTML:
function cartInfo(qty, amount) 
{ 
alert("hello"); 
 var itemCount = document.getElementById("<%= lblItemCount.ClientID %>"); 
  var total = document.getElementById("<%= lblTotal.ClientID %>"); 
   
  itemCount.value=qty; 
  total.value=amount; 
 itemCount.innerHTML="Item Count: " + qty; 
 total.innerHTML="Total: $" + amount; 
  <%=RadAjaxManager1.ClientID %>.AjaxRequest('itemCount'); 
                         
}
This code works perfectly fine. Now, my problem right now is that I have a login content page and when someone logs in, I want to call this javascript function so the header shows the correct information. When the login button is clicked, i want to run some vb code and THEN run the javascript code. How would i call a javascript function that waits for some server side code to run first before running it's own function? I have 2 textboxes for username and password and i have 2 other labels on the page that i've tried putting values into them to call an "onValueChanged" javascript event, but that doesn't work. When I try the "onClick" event for the button, it runs the javascript function, but it runs before the server code and the javascript function grabs the wrong data. Any ideas?
please let me know if more info/code is needed. thanks!
 
Back
Top