Thanks for teh info. Instead of using a public var I tried using a label on
teh form so that I could see the value.
I tried to 'alert' the value of teh label but it's not showing until after
teh js runs (then the label is set).
Basically here's all my js...
<script type="text/javascript">
//add event handlers to the search UpdatePanel
Sys.WebForms.PageRequestManager.getInstance().add_ beginRequest(startRequest);
Sys.WebForms.PageRequestManager.getInstance().add_ endRequest(endRequest);
function startRequest(sender, e) {
//disable controls during the AJAX call
document.getElementById("<%=Panel1.ClientID%>").di sabled = true;
}
function endRequest(sender, e) {
//re-enable controls once the AJAX call has completed
document.getElementById("<%=Panel1.ClientID%>").di sabled =
false;
if
(document.getElementById("<%=lblPublicMessage.Clie ntID%>").text != "")
alert(document.getElementById("<%=lblPublicMessage .ClientID%>").text);
}
</script>
This is an ajaxified webform. When I click my 'update db' button it runs
for a while (hence the js code to disable all the controls on the webform.)
In the vb.net code I set lblPublicMessage with a status. I would think it
would be between StartRequest and EndRequest.
When I tried to read lblPublicMessage it's either undefined or ''. After
the alert the label is updated.
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:O0**************@TK2MSFTNGP06.phx.gbl...
Well, the first thing I would do (if you haven't already) is do a View
Source to see if what you expected is what is really being sent to the
browser. Also, and this is just a personal preference, I do not completely
trust using the <%= %tags, so you may want to try using the methods
of Page.ClientScript instead. At what point do you change the value of
strMessage? One of the situations that has always been a real pain for me
when debugging in many cases is when the problem is caused by when I do
something. Hopefully some of this will help, good luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
"Cirene" <ci****@nowhere.comwrote in message
news:Ok**************@TK2MSFTNGP06.phx.gbl...
>>I have javascript code that does an alert on a public asp.net var...
alert("<%=strMessage%>");
The code runs whenever my ajax related code completes.
I declared the public var like this...
Public strMessage as string = "PUBLIC MESSAGE"
In my code I changed the variable but when the alert runs it always has
the original value, even though the var has been updated.
Any ideas why?