473,508 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing Client Callbacks Programmatically Without Postbacks in ASP.NET Web Pages

24 New Member
Hi Experts!

Apropos MSDN link:

http://msdn.microsoft.com/en-us/library/ms178208.aspx
[.NET Framework 4 - ASP.NET]
Implementing Client Callbacks Programmatically Without Postbacks in ASP.NET Web Pages

Using the code from the above link in the following code snippet, if you keep a break point on the statement "if (IsPostBack)" in the Page_Load event. The control moves into the "if (IsPostBack)" block after the alert, which mean that it is a Postback.

Then, how come you say "...Without Postbacks"?

I am getting confused here.

Can you help please?




Code Snippet:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASPCS2008ClientCallbacksProgrammatically._Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
  6.  
  7. <script runat="server">
  8.  
  9.     string aStringValue;
  10.  
  11.     public void RaiseCallbackEvent(String eventArgument)
  12.     {
  13.         aStringValue = eventArgument;
  14.     }
  15.  
  16.     public string GetCallbackResult()
  17.     {
  18.         return aStringValue;
  19.     }
  20.  
  21.     protected void Page_Load(object sender, EventArgs e)
  22.     {
  23.         ClientScriptManager cm = Page.ClientScript;
  24.  
  25.         String cbReference = cm.GetCallbackEventReference(this, "arg", "ReceiveServerData", "");
  26.  
  27.         String callbackScript = "function CallServer(arg, context) {" + cbReference + "; }";
  28.  
  29.         cm.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
  30.  
  31.         if (IsPostBack)
  32.         {
  33.  
  34.         }
  35.  
  36.         if (IsCallback)
  37.         {
  38.  
  39.         }
  40.     }
  41.  
  42. </script>
Expand|Select|Wrap|Line Numbers
  1. <html xmlns="http://www.w3.org/1999/xhtml" >
  2. <head runat="server">
  3.     <title></title>
  4.     <script type="text/javascript">
  5.         function ReceiveServerData(arg, context) {
  6.             Message.innerText = 'Processed callback.';
  7.         }
  8.     </script>
  9.  
  10. </head>
  11. <body>
  12.     <form id="form1" runat="server">
  13.     <div>
  14.         <input type="button" value="Callback"
  15.         onclick="CallServer(1, alert('Callback'))"/>
  16.         <br />
  17.         <span id="Message"></span>
  18.     </div>    
  19.     </form>
  20. </body>
  21. </html>

Thanks.
May 6 '10 #1
2 2536
Frinavale
9,735 Recognized Expert Moderator Expert
A callback is a special postback....but it's still a postback.

When a classic postback occurs the whole page is sent to the server, and the whole page is sent back to the browser.

When a callback occurs, the script callback doesn't redraw the whole page.

ViewState is not updated during a callback, but it is for postback.
May 6 '10 #2
qwedster
24 New Member
Thanks for the reply
May 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3064
by: A.M-SG | last post by:
Hi, Can I view/modify SOAP message at the client proxy side without using soap extensions? Thank you,
0
874
by: Papanii Okai | last post by:
Hi Guys Quick question. Is it possible to use Asp.net 2.0 client callbacks to refresh/update a datalist/repeater data control without a complete page postback? --Papanii
4
2920
by: Ashok | last post by:
Dear Friends, How to download a file from server to client local pc without user intervention ie without the save as popup window. Can you give me step by step. Thanks
1
1520
by: Philip | last post by:
I am using the ASP.NET v2 Client Callback facility to conduct partial page updates..... however part of the user interface problem is that the IE URL History is unaltered by my partial page update...
0
1020
by: ashwinirupert | last post by:
I have applied Master Pages to all my forms. Now I want to do client side scripting which I am not able to do. Please tell me how to attach Client side script to the pages.
3
3163
by: CodeRazor | last post by:
I have a user contol hosted in a webform. The user control interfaces with an http component. When the user control loads, a request is sent to the http component. It takes around 10 seconds...
3
1147
by: pbd22 | last post by:
Hi There. I think i need some software design help. I have a page, server.aspx, that starts uploading video files when it is loaded via hidden iframe by the client. On the same page is an...
1
1539
by: =?Utf-8?B?QU5lZWxpbWE=?= | last post by:
I have been reading about asp.net 2.0's client callbacks using the ICallbackEventHandler interface. I have also read that it is pretty much a light-weight AJAX type methodology and that it uses...
20
2605
by: =?Utf-8?B?V0o=?= | last post by:
I have a VC++ application that just crashes on one tester/client's machine. It runs fine everywhere else. What are the other options to debug (on the client's machine) without installing VC++...
1
11380
by: lmod | last post by:
I am developing an application using WPF and WCF. This app on the server side will need for WCF services hosted in IIS6 to communicate with WCF services that are hosted as Windows services on the...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.