Not sure if you have figured it out yet, but I think the problem is where you register your startup script. It should point to the page (page where the control is loaded) and not to the control itself. You can try : ScriptManager.RegisterStartupScript(this.Page,typeof(this.Page.getType()) ,"ScriptKey","alert('HI')", true); Hope this helps.
david vermeulen
Posts
-
WebUserControl, UpadtePanel And JavaScript Problem -
Asynchronous webmethodsHi, I am fairly new to asp.net and need a bit of help please. In our project we are doing a callback from the client-side to the server side using a webmethod in order to try and keep the page request alive. From what I can see in Firebug is that, on the server side, the webmethod is triggered successfully from the javascript until I start with my async event on the server side, then the webmethod waits for it to be finished before the javascript calls the pagemethod again. However this process of ours can take anything from 1 minute to 40 minutes, so it is quiet essential that I keep the page request alive. I don't want to increase the timeout on the scriptmanager since I don't think that is the right way to approach this issue. Here is a small sample of how the code code is: Java script:
function SimpleCallback() {
var lCurrentStatus = PageMethods.GetCurrentStatus(ProcessResults);
}function ProcessResults(pCurrentStatus) {
if (pCurrentStatus != "Completed") {
window.setTimeout("SimpleCallback()", 100);
}
}function SaveButtonClick(pArgument) {
var lAjaxManager = $find("<%= MyAjaxManager.ClientId %>");
lAjaxManager.ajaxRequest(pArgument);
SimpleCallback();
}<asp:Button ID="SaveButton" runat="server" Text="Save" OnClientClick="return SaveButtonClick('SaveStuff');"
Server side code:
[WebMethod]
public static string GetCurrentStatus()
{
return FCurrentStatus;
}protected void MyAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument == "SaveStuff")
{
FCurrentStatus = "ProcessRunning";
SaveInformation();
}
}//While this is being executed the webmetod, GetCurrentStatus, is ignored until this process is completed
delegate void MyLongRunningProcess();private void SaveInformation()
{
var lLongRunningMethod = new MyLongRunningProcess(NextClass.Save());IAsyncResult lResult = lLongRunningMethod.BeginInvoke(null, null);
while (!lResult.IsCompleted)
{
//Update progressbar with new percentage
}lLongRunningMethod.EndInvoke(lResult);
}Is there a way of doing the pagemethod call from javascript asynchronously, since it seems this is my problem. Or is there another way of approaching this in order to keep the page request alive? Thank you in advance, David.