views:

497

answers:

2

Hi friends,

This is different problem for me. I used ASP.NET2.0 with AJAX,C#.

Regularly client make request from HTML (client side) to any class(.cs) file(server side). And then make updation on that class files through Object or in database.

But I want to make request from Class file (server side) to HTML file (client side) based on that Object.

I m also used HashTable for containing Key and related to that Object.

If you are not able to understand then I try to Explain you my problem differently, I will give you one simple Example :I m calling any function from javascript to my class function, now I want call from class function to javascript function.

please explain me in brief, Please Help me.

+1  A: 

You can actually change the contents of an UpdatePanel during a partial page postback. So if the client clicks something on your ASPX page which alters your object on the server-side, you can update the controls on the ASPX page during that round trip.

If you need to simply update your view occasionally with no user interaction, then the ASP.NET AJAX Timer control will help.

DavGarcia
you are right but I want different things, Example:- In my database if any changes occurs then it will give response to the client, as per this you can use Classes or namespace instead of Database.
ashish bhatt
Yeah, that is impossible through a browser. There is no way for a server to fire an event on the client. The best workaround to this common problem is to have a timer on the client side that frequently requests updates from the server. The server then keeps track of all the things it needs to send.
DavGarcia
A year later... You can use a Publish/Subscribe service such as PubNub to publish events in your C# server side script then receive them in JavaScript on the client's browser in real time. http://www.pubnub.com/tutorial/csharp-push-api You'd still need your server side to probably do polling of the database to check for changes. Or get a SQL trigger to do a publish to PubNub on changes.
DavGarcia
A: 

There are three methods for interacting with server side code from the client side:

  1. Update panels: This uses a partial postback where the page essentially does a full postback to the server and then ignores everything except whats in the update panel then sends the result back.

  2. Page methods - This might not be quite what you are looking for since page methods require that the method be static on the page itself.

  3. Web service methods - These are the same web services you may use from your aspx code behind but you will need a script manager on the page to use them from javascript.

Corey Sunwold