asp.net-ajax

Detect ajax call, ASP.net

吃可爱长大的小学妹 提交于 2019-12-18 16:30:16
问题 how can I detect if a request is an AJAX-request (from jQuery) on the server-side of a ASP.net application. I don´t want to do this: mypage.aspx?this_is_ajax=true... ex. $.get("mypage.aspx"); On the server side I want to do certain things when the request is a ajax request... Thanks! 回答1: ASP.NET MVC had a great extension for this, that did work with JQuery. It checked it this way: Check the core collection: request["X-Requested-With"] == "XMLHttpRequest" Check the headers collection

Ajax.BeginForm inside Html.BeginForm

风格不统一 提交于 2019-12-18 12:58:22
问题 I have a view that is used for editing stuff, say Orders. Orders have line items that can be added arbitrarily. So a main view and nested partialviews. Each partial should have an ajax form for tweaking quantities of each line item or whatever. Thus: Html.BeginForm() {%> Ship to: blah blah blah <% Ajax.BeginForm("EditLineItem", "Order", new { OrderLineItemID = Model.ObjectID }, itemAjaxOptions)) { Item qty blah blah blah <--! (ajax form's submit button, etc.)--> } %> <--! (ajax form's submit

Is there a workaround for IE 6/7 “Unspecified Error” bug when accessing offsetParent

纵然是瞬间 提交于 2019-12-18 11:59:26
问题 I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page updates. The page allows a user to drop an item into a trashcan div, which will invoke a postback that deletes a record from the database, then rebinds the list (and other controls) that the item was drug from. All of these elements (the draggable items and the trashcan div) are inside an ASP.NET UpdatePanel. Here is the

How to specify javascript to run when ModalPopupExtender is shown

放肆的年华 提交于 2019-12-18 11:41:16
问题 The ASP.NET AJAX ModalPopupExtender has OnCancelScript and OnOkScript properties, but it doesn't seem to have an OnShowScript property. I'd like to specify a javascript function to run each time the popup is shown. In past situations, I set the TargetControlID to a dummy control and provide my own control that first does some JS code and then uses the JS methods to show the popup. But in this case, I am showing the popup from both client and server side code. Anyone know of a way to do this?

How can you tell if a method is being run in UpdatePanel postback?

梦想的初衷 提交于 2019-12-18 11:06:15
问题 How can I tell if a method is running in the context of an AJAX postback (i.e as the result of a UpdatePanel (asynchronous) postback)? According to egoldin Page.IsAsync is a very common confusion that has absolutely nothing to do with AJAX. The correct approach is to use ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack. 回答1: Use ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack 来源: https://stackoverflow.com/questions/265686/how-can-you-tell-if-a-method-is-being-run-in-updatepanel

Globally log exceptions from ASP.NET [ScriptService] services

点点圈 提交于 2019-12-18 10:55:19
问题 I'm using the [System.Web.Script.Services.ScriptService] tag to use web services callable from client side javascript. What I need is a way of globally logging any unhandled exceptions in those methods. On the client side, I get the error callback and can proceed from there, but I need a server-side catch to log the exception. The guy at this url: http://ayende.com/Blog/archive/2008/01/06/ASP.Net-Ajax-Error-Handling-and-WTF.aspx suggests that this can't be done. Is that accurate? Do I

Replace UpdatePanel with JQuery

徘徊边缘 提交于 2019-12-18 10:45:26
问题 I'm using UpdatePanel to asynchronously call a button click event in a page that calls a method in another class which writes out an XML file on the output. Is there a way to do this with JQuery instead of UpdatePanel? 回答1: Use jQuery to handle the click event. Then call a page method in the code-behind using this technique. From there you can write the XML file or do whatever else you want. 回答2: A simple alternative way to using jQuery to do ajax without the update panel is to use a build in

The required anti-forgery form field “__RequestVerificationToken” is not present in ajax call

天大地大妈咪最大 提交于 2019-12-18 09:53:32
问题 I have the following method in controller [HttpPost] [Authorize(Roles ="Klient")] [ValidateAntiForgeryToken] public ActionResult GetAvaiableHouses(DateTime startDate, DateTime endDate) { Session.Remove("Reservation"); IEnumerable <SelectListItem> avaiableHouses = repository.GetAllNamesAvaiableHouses(repository.GetAvaiableHousesInTerm(startDate, endDate)); List<string> houses = new List<string>(); avaiableHouses.ToList().ForEach(item => houses.Add(item.Value)); if(avaiableHouses.ToList().Count

Internet Explorer's Operation Aborted and Latency Issue

让人想犯罪 __ 提交于 2019-12-18 09:12:40
问题 If you don't know what the operation aborted error is, here's a Microsoft KB Article about it, http://support.microsoft.com/default.aspx/kb/927917 . There's also tonnes of posts about it but the simple answer for it's occurrence is this; the error only occurs if you try to manipulate a DOM element via JavaScript before the element you are trying to manipulate is loaded. I know how Internet Explorer's (IE) infamous Operation Aborted occurs and know how to fix it. The problem I have is a very

What causes the 'Cannot unregister UpdatePanel' error?

 ̄綄美尐妖づ 提交于 2019-12-18 04:38:12
问题 I've got a UserControl that contains an UpdatePanel. When I put that on a page, it throws the following error: Cannot unregister UpdatePanel with ID 'ReviewContentUpdatePanel' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported. Parameter name: updatePanel ReviewContentUpdatePanel is the name of the update panel & it's not being removed or added in code, it exists in the aspx