By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Asynchronous Callback Not Updating Web Page???

P: n/a
TC
Hello,

I am making an asynchronous call to a webservice and trying to update the
web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender, System.EventArgs e)
{
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}
Regards,

TC
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
if you are calling web service from an ASP.Net page on the server side, you
need wait till the call completes. use IAsynchResult.WaitHandle.WaitOne()
check this if you need more info..
http://msdn.microsoft.com/library/de...ce09032002.asp

Av.
http://www.avnrao.blogspot.com
"TC" <ge**********@yahoo.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am making an asynchronous call to a webservice and trying to update the
web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender, System.EventArgs e)
{
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}
Regards,

TC

Nov 18 '05 #2

P: n/a
TC
Hey folks,

I need C# assistance for non-blocking, asynch callback from the web page.

I am currently receiving the appropriate values back but the page does not
update.

Does anyone know why?

Regards,

TC
"avnrao" <av*@newsgroups.com> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
if you are calling web service from an ASP.Net page on the server side, you need wait till the call completes. use IAsynchResult.WaitHandle.WaitOne()
check this if you need more info..
http://msdn.microsoft.com/library/de...ce09032002.asp
Av.
http://www.avnrao.blogspot.com
"TC" <ge**********@yahoo.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am making an asynchronous call to a webservice and trying to update the web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender, System.EventArgs e) {
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}
Regards,

TC


Nov 18 '05 #3

P: n/a
Hello,

ASP.NET application uses request/response architecture, and it may not be
suitable for asynchronous call to a web service. Regarding your code:

private void btnStartFileSearch_Click(object sender, System.EventArgs e)
{
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

After BeginWordCount, the response will be write back to client, won't wait
here. You have to use synchronous call here.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4

P: n/a
You initiate the call but don't wait for the result. The goal of an
asynchornous call is for example :
- make the call to a web service
- do some work
- get the result (will still wait if not already available)

That way you can do some work in parallel.

If you need the result from the webservice and you have nothing to do in
between making an asynchronous call is useless.

Patrice
"TC" <ge**********@yahoo.com> a écrit dans le message de
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am making an asynchronous call to a webservice and trying to update the
web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender, System.EventArgs e)
{
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}
Regards,

TC

Nov 18 '05 #5

P: n/a
TC
Actually, the idea would be to free up the GUI so that a user isn't stuck.
That makes an asynch call very useful. Then the user can do whatever work
they wish to and when the webservice returns the appropriate information,
the application can finish the work behind the scenes.

At least this is what I am trying to do.

Todd


"Patrice" <no****@nowhere.com> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
You initiate the call but don't wait for the result. The goal of an
asynchornous call is for example :
- make the call to a web service
- do some work
- get the result (will still wait if not already available)

That way you can do some work in parallel.

If you need the result from the webservice and you have nothing to do in
between making an asynchronous call is useless.

Patrice
"TC" <ge**********@yahoo.com> a écrit dans le message de
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am making an asynchronous call to a webservice and trying to update the web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender, System.EventArgs e) {
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}
Regards,

TC


Nov 18 '05 #6

P: n/a
"TC" <ge**********@yahoo.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am making an asynchronous call to a webservice and trying to update the
web page with the results.

The page is not updating.

Does anybody know why???
Yes. Your page does not exist when your callback is called.
private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}


When this method is called back, the request has already completed, the
response has already been sent to the client, and you are out of luck.

I recommend that you find some sample code which does this and follow that
example. I can recommend it because you're not going to find any such sample
code - the entire idea is contrary to the way that ASP.NET works.

See
http://msdn.microsoft.com/library/de...singstages.asp.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #7

P: n/a
Humm. Sorry if I restate something ovbious...

The page the user sees is just some HTML that is rendered by the server side
APSX page. Once the ASPX page is finished the user see client side HTML code
and the page doesn't exist any more server side. You nedd then another HTTP
request to be in touch again with server side code.

I see basically two options :

- you need the webservice call to be completed to have a meaningfull page :
- out of luck, needs to wait the result from the webservice to construct
the final HTML page
- use an IFRAME that calls an ASPX page that calls this webservice. The
user can see a part of the final UI (done by the main ASPX page) but will
have still to wait a bit to see the inner frame content(done be the ASPX
page referenced by the IFRAME). Of course, if the webservice is quite
qucik,, the first optino is probably still the simpler.

- you don't need the webservice call to be completed (will be used sometimes
later)
- you could queue these calls to have them done seperately from the user
page (AFAIK .NET proivides something along these lines was called MSMQ
previously)

Do you recognize a case in which you are ?

Patrice
"TC" <ge**********@yahoo.com> a écrit dans le message de
news:es**************@TK2MSFTNGP11.phx.gbl...
Actually, the idea would be to free up the GUI so that a user isn't stuck.
That makes an asynch call very useful. Then the user can do whatever work
they wish to and when the webservice returns the appropriate information,
the application can finish the work behind the scenes.

At least this is what I am trying to do.

Todd


"Patrice" <no****@nowhere.com> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
You initiate the call but don't wait for the result. The goal of an
asynchornous call is for example :
- make the call to a web service
- do some work
- get the result (will still wait if not already available)

That way you can do some work in parallel.

If you need the result from the webservice and you have nothing to do in
between making an asynchronous call is useless.

Patrice
"TC" <ge**********@yahoo.com> a écrit dans le message de
news:uN**************@TK2MSFTNGP10.phx.gbl...
Hello,

I am making an asynchronous call to a webservice and trying to update the web page with the results.

The page is not updating.

Does anybody know why???

Below is my code:

public class ASPNetSuperhero : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
protected System.Web.UI.WebControls.TextBox txtMessage;
protected System.Web.UI.WebControls.Button btnStartFileSearch;

private localhost.ASPNetSuperheroService GetWordCount;
protected System.Web.UI.WebControls.Label lblWordCount;
private AsyncCallback MyWordCountCallback;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnStartFileSearch.Click += new
System.EventHandler(this.btnStartFileSearch_Click) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void btnStartFileSearch_Click(object sender,
System.EventArgs
e) {
MyWordCountCallback = new AsyncCallback(WordCountCallback);
/* Create new instance of the webservice that provides
the required functionality*/
GetWordCount=new localhost.ASPNetSuperheroService();
GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
}

private void WordCountCallback(IAsyncResult Result)
{
// Call the webservice method in order to get current word count
this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
}
}
Regards,

TC



Nov 18 '05 #8

P: n/a
TC
Hey Folks,

Thanks for the help!

Basically, because what I wish to do is contrary to the way in which ASP
works, I'm just gonna wait for the response to return.

Thanks Again,

TC

"Patrice" <no****@nowhere.com> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
Humm. Sorry if I restate something ovbious...

The page the user sees is just some HTML that is rendered by the server side APSX page. Once the ASPX page is finished the user see client side HTML code and the page doesn't exist any more server side. You nedd then another HTTP request to be in touch again with server side code.

I see basically two options :

- you need the webservice call to be completed to have a meaningfull page : - out of luck, needs to wait the result from the webservice to construct the final HTML page
- use an IFRAME that calls an ASPX page that calls this webservice. The user can see a part of the final UI (done by the main ASPX page) but will
have still to wait a bit to see the inner frame content(done be the ASPX
page referenced by the IFRAME). Of course, if the webservice is quite
qucik,, the first optino is probably still the simpler.

- you don't need the webservice call to be completed (will be used sometimes later)
- you could queue these calls to have them done seperately from the user page (AFAIK .NET proivides something along these lines was called MSMQ
previously)

Do you recognize a case in which you are ?

Patrice
"TC" <ge**********@yahoo.com> a écrit dans le message de
news:es**************@TK2MSFTNGP11.phx.gbl...
Actually, the idea would be to free up the GUI so that a user isn't stuck. That makes an asynch call very useful. Then the user can do whatever work they wish to and when the webservice returns the appropriate information, the application can finish the work behind the scenes.

At least this is what I am trying to do.

Todd


"Patrice" <no****@nowhere.com> wrote in message
news:uF**************@TK2MSFTNGP09.phx.gbl...
You initiate the call but don't wait for the result. The goal of an
asynchornous call is for example :
- make the call to a web service
- do some work
- get the result (will still wait if not already available)

That way you can do some work in parallel.

If you need the result from the webservice and you have nothing to do in between making an asynchronous call is useless.

Patrice
"TC" <ge**********@yahoo.com> a écrit dans le message de
news:uN**************@TK2MSFTNGP10.phx.gbl...
> Hello,
>
> I am making an asynchronous call to a webservice and trying to update
the
> web page with the results.
>
> The page is not updating.
>
> Does anybody know why???
>
> Below is my code:
>
> public class ASPNetSuperhero : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.DropDownList drplstFilePaths;
> protected System.Web.UI.WebControls.TextBox txtMessage;
> protected System.Web.UI.WebControls.Button btnStartFileSearch;
>
> private localhost.ASPNetSuperheroService GetWordCount;
> protected System.Web.UI.WebControls.Label lblWordCount;
> private AsyncCallback MyWordCountCallback;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> }
>
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form

Designer. > //
> InitializeComponent();
> base.OnInit(e);
> }
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> this.btnStartFileSearch.Click += new
> System.EventHandler(this.btnStartFileSearch_Click) ;
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
>
> private void btnStartFileSearch_Click(object sender,

System.EventArgs
e)
> {
> MyWordCountCallback = new AsyncCallback(WordCountCallback);
> /* Create new instance of the webservice that provides
> the required functionality*/
> GetWordCount=new localhost.ASPNetSuperheroService();
> GetWordCount.BeginWordCount(MyWordCountCallback,Ge tWordCount);
> }
>
> private void WordCountCallback(IAsyncResult Result)
> {
> // Call the webservice method in order to get current word count
> this.txtMessage.Text=GetWordCount.EndWordCount(Res ult);
> }
> }
>
>
> Regards,
>
> TC
>
>



Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.