asp.net-ajax

Detect ajax call, ASP.net

梦想与她 提交于 2019-11-30 13:28:20
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! 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 (ensuring its not null): request.Headers["X-Requested-With"] == "XMLHttpRequest" It did it as an extension method,

Print contents of a modal popup

我只是一个虾纸丫 提交于 2019-11-30 09:52:33
问题 I have an application that shows a list of items. The user can click on an item and see its details in a modal popup (centered DIV, shown using JavaScript). I need to have a button on that popup that will allow the user to print out the contents of the modal popup only. This is for an internal application that needs to work in IE7+ only. When the user clicks the print button on the modal popup the state of the item gets changed to "printed" (for internal business reasons...). I am using ASP

AJAX progress bar dispaying loading progress percentage for page load

倾然丶 夕夏残阳落幕 提交于 2019-11-30 09:35:32
问题 How do you use a progressbar to show the loading percentage for a page? ...(similar to how they show in flash) Thanks 回答1: Impossible(on IE8 & FF3 & Opera without plugin or extension). If you want real loading percentage include HTML + Javascript + Stylesheet + Image. you can only detect how many file loaded to page(only Image & javascript can be detected by this technique). 回答2: I would say that if you need a progressbar for a page, that page might need some rethinking. Personally I don't

Message: Invalid JSON primitive: ajax jquery method with Webmethod

拈花ヽ惹草 提交于 2019-11-30 08:12:45
I am using Data value as object literal, instead of concatenating a String as explained in this answer My code is the following: $.ajax({ url: "../Member/Home.aspx/SaveClient", type: "POST", async: false, dataType: 'json', contentType: 'application/json; charset=utf-8', data: { "projectSoid": ProjectId, "startDate": StartDate, "endDate": EndDate, "clientManager": ClientManager }, success: function(response) { if (response.d != "") { } }, error: function(response) { var r = jQuery.parseJSON(response.responseText); alert("Message: " + r.Message); alert("StackTrace: " + r.StackTrace); alert(

Ajax.BeginForm doesn't call onSuccess

吃可爱长大的小学妹 提交于 2019-11-30 05:26:23
问题 In ASP.NET MVC 3 application I use Ajax.BeginForm to post writed text to controller. @using (Ajax.BeginForm("Post", "Forum", new {threadId = Model.Thread.Id }, new AjaxOptions { OnSuccess = "PostReply" })) { <div id="reply-area"> <h3 style="border-bottom:1px solid black">POST REPLY</h3> <span id="post-error" class="error-message"></span> <textarea rows="1" cols="1" id="post-textarea" name="Content"> </textarea> <input type="submit" class="button" value="Submit"/> </div> } In controller I have

Post form data to Controller's action with Ajax

梦想与她 提交于 2019-11-30 05:21:39
I have a page in MVC3, with a link (Ajax.ActionLink). When user clicks it, it calls controller's action, and the result is inserted into a div, with replace. Code is shown below: @Ajax.ImageActionLink("/Images/btn_share.png", "Share pool", "SharePool", new { poolKey = Model.Id, poolName = Model.Name }, new AjaxOptions { UpdateTargetId="popup", HttpMethod="GET", InsertionMode = InsertionMode.Replace, LoadingElementId="loading_dialog", OnSuccess = "ShowPopup('#popup_share', true, true)" } ImageLinkAction is custom extension method to use image as link, and ShowPopup is a javascript function that

How to specify javascript to run when ModalPopupExtender is shown

随声附和 提交于 2019-11-30 04:15: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? BTW, I needed this because I have a textbox in the modal that I want to make a TinyMCE editor. But the

asp.net mvc 3 - ajax form submit and validation

╄→гoц情女王★ 提交于 2019-11-30 03:39:24
I am sorry if this has been asked already, but I have been looking for sometime but all I have found are rather old posts (mvc1, mvc2). I have a form which I would like to submit via Ajax. This looks like it would work but does not cover server side validation. 1) I am unsure if I should use the AjaxHelper.BeginForm or use raw jquery calls ($.ajax) ? What is the recommended approach here? 2) How do I handle client and server side validation? I am hoping the mvc framework provides a built in mechanism for dealing with this? There are some validations which I am only doing server side. Would

Html.RenderPartial and Ajax.BeginForm -> Submit is called twice

て烟熏妆下的殇ゞ 提交于 2019-11-30 01:58:46
I have the following index view: @model BoringStore.ViewModels.ProductIndexViewModel @{ ViewBag.Title = "Index"; } <h2>Produkte</h2> <div id='addProduct'> @{ Html.RenderPartial("Create", new BoringStore.Models.Product()); } </div> <div id='productList'> @{ Html.RenderPartial("ProductListControl", Model.Products); } </div> The "productList" is just a list of all products. The addProduct renders my Create View: <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> <div id="dialog-confirm" title="Produkt hinzufügen" style="display:none"> @using

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

我的未来我决定 提交于 2019-11-30 01:50:28
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. Use ScriptManager.GetCurrent ( Page ).IsInAsyncPostBack 来源: https://stackoverflow.com/questions/265686/how-can-you-tell-if-a-method-is-being-run-in-updatepanel-postback