asp.net-ajax

ASP.NET Register Script After Partial Page Postback (UpdatePanel)

て烟熏妆下的殇ゞ 提交于 2019-12-01 01:40:10
I have a simple form (textbox, submit button) which is wrapped in an update panel. <asp:UpdatePanel ID="ReplyUpdatePanel" UpdateMode="Conditional" runat="server"> <ContentTemplate> <asp:Textbox id="ReplyTextBox" runat="server"/> <asp:Button id="SubmitButton" OnClick="SubmitButton_Click" runat="server"/> <ContentTemplate> </asp:UpdatePanel> So, when i click the button, the server-side click event is fired (SubmitButton_Click), stuff happens to the db, and the page is re-rendered (asynchronously). Here's my issue - i need to execute some JavaScript after all the "stuff happens to the db". In

ASP.Net Ajax - PageMethods Synchronous call and retrieval of results

无人久伴 提交于 2019-12-01 00:26:29
How to ASP.Net Ajax - PageMethods Synchronous call and retrieval of results ? Currently i am doing following async call and working with data : function checkName(name) { PageMethods.IsAvailable(name, onSuccess); } function onSuccess(result, context, method) { //... do something with result .... } How can i do same synchronously with result ? IMHO this is not possible with ASP.NET AJAX because the generated wrappers use async calls. By the way you could use jQuery to call the PageMethod where it is a matter of setting async: false . 来源: https://stackoverflow.com/questions/1957600/asp-net-ajax

How to avoid “Response.Redirect cannot be called in a Page callback”

夙愿已清 提交于 2019-11-30 22:34:34
问题 I'm cleaning up some legacy framework code and a huge amount of it is simply coding by exception. No values are checked to see if they are null, and as a result, copious amounts of exceptions are thrown and caught. I've got most of them cleaned up, however, There are a few error / login / security related framework methods that are doing Response.Redirect and now that we are using ajax, we are getting ALOT of "Response.Redirect cannot be called in a Page callback." And I'd like to avoid this

ASP.Net button click event not firing

旧时模样 提交于 2019-11-30 22:01:39
This is perhaps related to this question , but I have slightly more information. I recently updated an ASP.Net application to .NET 3.5 after coding a few new pieces with Linq. Now my pages intermittently stop firing event handlers. I have it narrowed down to pages with Ajax on them, and I assume it's either the ScriptManager or the AjaxControlToolkit registration that is precipitating the problem. The really screwy part is that pages seem to work fine about 2/3s of the time, and the controls lose their event handlers only 1/3 of the time. I wondered about some type of error occurring and the

Is it good to use jQuery AJAX with traditional true?

心已入冬 提交于 2019-11-30 21:04:30
问题 First, I don't know what traditional means in Ajax setting, Second, is there any case we need set it to be true in ASP MVC? Based on the name, I believe it's going to be depreciated soon? Isn't it? 回答1: jQuery API documentation http://api.jquery.com/jQuery.Ajax/#jQuery-ajax-settings traditional Type: Boolean Set this to true if you wish to use the traditional style of param serialization. Let's have a look below, tranditional flag changes the way how parameters are sent to the server For PHP

ASP.Net Ajax - PageMethods Synchronous call and retrieval of results

北战南征 提交于 2019-11-30 19:10:17
问题 How to ASP.Net Ajax - PageMethods Synchronous call and retrieval of results ? Currently i am doing following async call and working with data : function checkName(name) { PageMethods.IsAvailable(name, onSuccess); } function onSuccess(result, context, method) { //... do something with result .... } How can i do same synchronously with result ? 回答1: IMHO this is not possible with ASP.NET AJAX because the generated wrappers use async calls. By the way you could use jQuery to call the PageMethod

setInterval stops after Ajax request

☆樱花仙子☆ 提交于 2019-11-30 16:34:47
I'm using Asp.net MVC and I want my partial view to refresh on an interval, which it does until I make an unrelated Ajax request, then it stops. Here are a few simplified snips to illustrate the problem. in AjaxRefresh.js: function ajaxRefresh() { var f = $("#AjaxForm"); $("#AjaxLoading").show(); $.post(f.attr("action"), f.serialize(), function (context) { $("#AjaxDiv").html(context); $("#AjaxLoading").hide(); }); } setInterval(ajaxRefresh, 1000); in Index.aspx: <script type="text/javascript" src="../../Scripts/AjaxRefresh.js"></script> <div id="AjaxDiv"> <% Html.RenderPartial("Computers",

Adding PostBackTriggers and AsyncPostBackTriggers to UpdatePanel for dynamically-generated grandchild controls

喜你入骨 提交于 2019-11-30 14:39:34
I have a page with a ScriptManager, a generic HTML drop-down list ( <select> ), and an UpdatePanel. The UpdatePanel contains a PlaceHolder (for now). During Page_Load, a number of user controls are added to the PlaceHolder (really, it's several instances of the same user control). The number to add is not known until the page loads, so they do need to be loaded dynamically. The drop-down list is populated with the same number of menu items, and there is javascript on the page also (using jQuery) to show only one of the controls at a time depending on the state of the drop-down list. Each user

How to control which JavaScript gets run after UpdatePanel partial postback endRequest?

寵の児 提交于 2019-11-30 14:17:25
I know I can hook into the client side events to run JavaScript after every partial postback; however, I want to do something like this: protected void FooClicked(object sender, EventArgs e) { ClientScript.RegisterStartupScript(GetType(), "msg", "showMsg('Foo clicked');",true); } I know I could totally hack it with hidden fields and run something after every postback, but there should be a pretty straightfoward way to in a similar fashion to this. The specific code sample you are describing does not work with partial post-backs, since ClientScript.RegisterStartupScript() writes JS to the page

Message: Invalid JSON primitive: ajax jquery method with Webmethod

爷,独闯天下 提交于 2019-11-30 13:42: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