How To Make A Concurrent AJAX WCF Web Service Request During An Async Postback
May 22, 2010
I want to provide status updates during a long-running task on an ASP.NET WebForms page with AJAX.Is there a way to get the ScriptManager to execute and process a script for a web service request concurrently with an async postback? I have a script on the page that makes a web service request. It runs on page load and periodically using setInterval(). It's running correctly before the async postback is initiated, but it stops running during the async postback, and doesn't run again until after the async postback completes.
I'm working on adding a todo list to a project system and would like to have the todo creation trigger a async postback to update the database. I'd really like to host this in a usercontrol so I can drop the todo list onto a project page, task page or stand alone todo list page.
Here's what I have.User Control "TodoList.ascx" which lives in the Controls directory.
The script that sits at the top of the UserControl. You can see where I started building jsonText to postback but when that didn't work I just tried posting back an empty data variable and removed the 'string[] items' variable from the AddTodo2 method.
<script type="text/javascript"> $(document).ready(function() { // Add the page method call as an onclick handler for the div. [code]...
I can have a control that can be used to display multiple todo lists and create a brand new todo list as well.When I click on the #divAddButton I can watch it build the postback in firebug but once it completes it runs the error portion by alerting 'error'. I can't see why.
I'd really rather have the response method live inside the user control as well. Since I'll be dropping it on several pages to keep from having to go put a method on each individual page.
I have a series of div's inside an update panel, these divs have a margin-bottom defined in css. In IE8, when I do a async postback these margins are all removed. All the other styles are fine. If I turn on compatibility mode this does not happen. In Google Chrome the margins are maintained correctly after the async postbacks.
I am creating a ASP.Net server control to manage locations. The control is a composite control containing several text-boxes, labels, and a link button. I use the AJAX Control Toolkit to provide a modal popup which contains a Bing map. All the Javascript is in its own file and used as an embedded web resource.
The link button is what opens the modal popup. It also needs to call a Javascript function that initializes the Bing map (onclick = "GetMap();"). There are instances when this server control is placed within an Update Panel (and there is no way to avoid this). When in an Update Panel the link button loses its onclick event. I understand that this is because during an async postback the portion of the DOM that defines the content of the Update Panel is thrown out and reinitialized, resulting in the event breaking. When the control is not in an Update Panel everything works as intended.
I have tried registering events on Page.Load and Page.Init, like so:
[Code]....
I have also tried flat out writing the function call to the page:
[Code]....
I have put breakpoints on the lines inside each delegate and they do not get hit. I am not aware of any special way to register events of a composite control's child control or the Page.Load/Page.Init events when being done inside a server control. Is there some special way to register these events? (Note: Both those code blocks above are in my CreateChildControls() method)
Below is the GetMap() Javascript function. As you can see it is pretty straight forward.
I've got a problem that after i refresh an update panel all the HoverMenu's stop displaying, it still calls the WebMethod which returns valid html and the panel is displayed, but it content of the panel isn't displayed on the browser.
I've created a single page to demo this problem:
aspx
[Code]....
vb.net
[Code]....
The demo shows the hovermenu working until you click the update button then it stops showing the content, although it is still calling the WebMethod onhover.
I am using VS2008, .net Framework 3.5 and toolkit 3, 0, 30930, 0
I'm trying to create a modal popup that has multiple buttons that a user will click to choose options. This is all well and good but when the user clicks an option it fires a full postback. The modal opens async, but I can't get it to hide async. Heres some code:
I have several ASP.NET sites, hosted on the same domain (different subdomains) and working via HTTPS.I have WCF service, hosted on the same domain.I have a separate state server for sessions. why - i will reply later, but it's a 'must') On my sites, I use grid components from Telerik (but actually it does not matter) that ask for data from WCF service and must be filled with this data.I cannot manage to make POST request to WCF service from javascript: for some reason it's always either GET or OPTIONS (no matter if I use Sys.Net.WebServiceProxy invoke or just a plain jquery AJAX request). It happens even if I indicate COOKIE mode
this has probably been discussed before but perhaps not enough as I haven't been able to find any literature on this method (parts are documented, but not as a whole I guess)Anyways, you start with a web service, and you call that web service client side with ASP.NET AJAX javascript. Once you get a reply, you can call a artial postback using __doPostback(a, b) and "a" is the control id of an updatepanel in your page and "b" can be an indicator for which web service you are using or your resulting data or both. Lastly you add a check for "a" and "b" like this:
[Code]....
Now you can execute any code behind function when you receive a response, and because it's async anything short of leaving the page and it will still postback when you get a response.For example, I have a site which display data from a database in a gridview and uses a client side web service to get the time last updated for a database, call the web service client side every second, then, when an update is detected, call a partial postback, alert the user, and update the gridview.Though this really is a hack, so I'm not sure if there any problems with this approach, if there's a simpler and better way to go about it (I'm all ears).
Dim iCounter as Integer Dim iQuantity as Integer = 10 Protected Sub btnFoo_Click Handles btnFoo Yadda For i as Integer = iCounter to iQuantity - 1 //do something with AsyncPostBackTrigger until iCounter = iQuantity - 1 //then trigger a full postback Next End Sub
I am new to the concept and feel like there must be something really easy that I am missing.
This is so frustrating to me. I'm doing this via standard .NET 2.0+ web services (not WCF). My application is in .NET 3.5 but I'm just adding a service reference. I've not done any SOAP WSDL sending before. I've used NVP which to me seems much more error prone and burdensome because you have to create all the wrappers yourself and if any of that third party API changes, it breaks your code. I have not a clue how to make a call using the latest PayPal WSDL. I added the service reference and I see proxy classes such as [className]Request and [className]Response but how do you actually make the CALL and send the request over the wire?
I see people have used the outdated (.NET 1.1) PayPal SDK. We do not want to use an SDK just to send a request. Isn't it much easier nowdays in .NET when using any SOAP API to invoke the request? People for example using PayPal are relying on a caller class from that SDK but again it's way, way outdated. So onto today, .NET 2.0+, I thought that you don't need all that plumbing anymore?
How would I do this? I see no good documentation on the net period on .NET 2.0 or 3.5 web services especially SOAP and it's frustrating. Sure add the service reference, use the WSDL and proxy generated class wrappers but outside this HOW to make a request is impossible to find. I'm seeing legacy ways of doing this in .NET and then I hear this is all done under the covers for you in .NET..I guess that must be .NET 2.0+ ?? Is it as simple as just making the proxy class method calls and .NET under the covers takes care of the plumbing to actually send the request over Http unlike .NET 1.1 where you had to do all the plumbing yourself?
I have a page that contains a user control. Can i make an ajax request directly to the control? I know I can make an ajax request to .aspx or .ashx; however, is it possible to go direct to the .ascx?
Frameworks like Node.js, Tornado, and Twisted let developers create server-push applications that supports large number of concurrent hanging requests (10k+). From what I understand, they all achieve this by not creating threads to service each hanging request.
Can AsyncController be used to service large number of inactive concurrent requests?If so, are there any reasonably large ASP.NET MVC websites using this approach to create long-poll applications?
i'm just getting started with asp.net and ajax. My question is : is it possible to make an ajax request and simulate the server response in the code behind. in other words can the request be sent to the code behind of the same page? if it's possible haw can i perform this ?
I am new to WCF, I was using web service asmx before. I have trouble on making my wcf JSON ajax service work through http like asmx.Could you help me see what wrong in my code?My WCF services are defined in my website application folder. My aim is to call this service in my aspx page java-script code and return complex object back as JSON to my javascript. I have no problem on doing this through classic asmx web service.
When I try to test it through my browser by type this in the URL , URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc/GetAll. it return "Method not allowed."
But if I type just this URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc, it return this:
WCFCompanyService Service
You have created a service.To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:
C#
class Test { static void Main() { HelloClient client = new HelloClient();
somepartialview calls other partial views, that also contains client javascript. This loads and works fine, the javascript-based effects (vertical ticker, horizontal ticker) work fine as well.
The problem is that somepartialview has several AJAX.ActionLink(s) like this:
Ajax.ActionLink("LinkText", "SetIcons", new { id = l.ID }, new AjaxOptions { UpdateTargetId = "ajaxdiv" }) Namely, an <a> element which upon click changes the content of <div id="ajaxdiv"> using a 'SetIcons' controller:
[Code]....
But this works only partially: the page gets refreshed with the new HTML content, but the scripts that worked before the async postback do not run anymore. How do I get them to work?
I think that I am looking for the MVC alternative of the WebForms' ScriptManager.RegisterStartupScript
I have a web application that does some complicated data retrieval tasks and so I am trying to show a modal dialog box with a loading message when the tasks begins. I am using ASP.Net 3.5, the jQeury popup I am using is bPopup.
Firstly, I have a table where the rows can be clicked. Im am using a script from[URL] to do an async postback from the table row. Here is my function
[Code]....
so the $("#<%=lDiv.ClientID %>").openPopup(); opens up my loading modal and then the server starts doing its thing. When the server finishes though how would I then close the dialog box?
I just need to call one line of code like $("#<%=lDiv.ClientID %>").closePopup();
I know about Always vs. Conditional, I just need to know exactly which update panel's data needs to be refreshed (not taken from app tier cache) on the serverside.
I have placed a user control inside update panel after doing asynchronous postback of page associated js file of that user control is not working so that is there any method to exclude a control from updatepanel in another word i don't want to post that user control.
<asp:UpdatePanel ID="upPnlAnswerList" runat="server"> <ContentTemplate> // another code that required to placed inside updatepanel <div id="miancontainer" class="containerr" <klmsuc:Share ID="shareUserControl" runat="server" /> [code]...
For example, I have three UpdatePanels on the page. I click a button, and I get pretty long response, that contains all the data for the three UpdatePanels, the viewstate string.
I want to optimize my query and receive response like "ok" or "not ok". How can I do that?
I need to gather information (via GET) from several other websites (not under my control), do some processing (specific to each source) on the data returned, and then print all the info out to the user.
Right now I'm making the GET request to website A, waiting for it to return, processing it, then calling website B, and so on... Obviously this is too damn slow. I'd like to make async requests to A, B, and C, then process each response as it comes back, and once I have all the responses, print it all out to the user.
I'm allowed to use classic asp or vb.net. I'm more familiar with classic asp but I'm willing to learn...
I have multiple update panels with various asp buttons on a single page. I want to disable the buttons which caused the postback in update panel untill it completes.
Is there a way to avoid using a third party control for this? through JQuery or any other method ?
I have a webservice which works 100% fine on my developer machine. Where Web Service is installed on LOCALHOST on my developer machine,Then i went to my servers, I installed webservice on one server and map it with the server where the website is hosted, Then i tried accessing this service using BROWSER from my web server, it worked fine, That means the mapping was done perfect.Then i run my program on web server (website). It worked fine on page1, then on page2, but when i did the same and call same function on page3, It popped me any error of
...I get an async postback when I click the 'Edit' button for a particular GridView row. This is what I want. In fact, I also get an async postback if I then click the 'Cancel' button for that GridView row which appears after having clicked the 'Edit' button.
However, if I instead click the 'Update' button that appears after having clicked the 'Edit' button, I get a full postback. I have tried almost every GridView EventName
I can find to add to the <Triggers></Triggers> section to get a click of the 'Update' button to result in an async postback, but with no luck.
What EventName should I use in the <Triggers></Triggers> section to get a GridView to do an async postback when clicking the 'Update' button for a particular row?
I have a WCF service returning JSON to jQuery ajax calls and presenting the results on an ASPX page. When the page is NOT under SSL, the ajax calls work perfectly. When the page IS under SSL, the calls fail. I understand that this behavior must be due to the Same Origin Policy (SOP).
So, how do I setup my WCF service to accept calls from an SSL-secured page? Does the WCF service also need to be secured? If so, how do I do this?