asp.net-ajax

How do I force ASP.NET Ajax to use a script from the FS and not WebResource.axd, or to reduce its HTTP requests?

点点圈 提交于 2019-12-08 06:31:17
问题 Here is a hum-dinger of a problem that I have not found an answer for. I am using the ASP.NET ajax control toolkit controls on a few pages, which by nature want to load script resources via WebResource.axd. This is all well and good for some applications, but each call to WebResource.axd requires an HTTP request. Most pages will pull at least 3 or 4 resources from the WebResource.axd, so this many HTTP requests are issued for each page. Since having too many HTTP requests will negatively

Ajax.ActionLink, get data or error message from controller?

蹲街弑〆低调 提交于 2019-12-08 04:54:30
问题 Here is a spot that I want to update: <div style="text-align: center;" id="vote_count">@Html.DisplayFor(q => q.VoteCount)</div> Here is my actionLink: @Ajax.ActionLink("Upvote", "Upvote", "Author", new { QuestionID = Model.QuestionID, @class = "upvote" }, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "vote_count", OnBegin = "onBegin", OnComplete = "onComplete", OnSuccess = "onSuccess", OnFailure = "onFailure" }) And here is one of my controllers: public int Upvote

Hide Textbox Targeted by the ColorPickerExtender

ε祈祈猫儿з 提交于 2019-12-08 04:30:03
问题 Is there a way to hide the textbox that is targeted by the colorpickerextender in the newest release of the ajax control toolkit? If you add style="display:none" to the textbox, then the color picker shows up in the top left corner of the browser window. I want it to show up near the button that is referenced in the extenders popupbuttonid. I want to hide the textbox because I don't want the user to see the color code. 回答1: While I didn't hide it, I did find another way to get what I wanted.

ASP.Net AJAX JavaScript Serialization Error

末鹿安然 提交于 2019-12-08 04:11:29
问题 Ran into an “Out of Stack Space” error trying to serialize an ASP.Net AJAX Array object. Here is the scenario with simplified code: Default.aspx MainScript.js function getObject(){ return new Array(); } function function1(obj){ var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); } function function2(){ var obj=getObject(); var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); alert(s); } Content.aspx ContentScript.js function serializeObject(){ var obj=window.top

How can I have an ascx postback and refresh itself automatically every X seconds?

假如想象 提交于 2019-12-08 04:03:40
问题 I have an ascx control bound to a datasource with frequently changing data. Is there a quick way to have an ascx control postback, rebind and refresh itself every X seconds. The ascx control is in an update panel. 回答1: Use a timer control from the AJAX toolkit since you are already using it: <asp:Timer ID="tmrPolling" runat="server" Interval="10000" ontick="tmrPolling_Tick"></asp:Timer> Add a trigger to your update panel like: <Triggers> <asp:AsyncPostBackTrigger ControlID="tmrPolling"

Url.Action: How to Pass Parameter from View to Controller?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 03:59:30
问题 I'm having issues with passing a parameter from my View to Controller using Url.Action. My code is the following in the View: <form id="searchForm"> <input type="text" name="search_criteria" /> <input type="submit" value="Search" /> </form> <div id="SearchDiv"> </div> In my Script: $('#searchForm').submit(function (e) { e.preventDefault(); $.ajax({ url: '@Url.Action("Index_AddSearchCriteria", "Home", "search_criteria")', type: 'POST', dataType: 'html', success: function (result) { $('

Calling ASP.NET MVC Controller explicitly via AJAX

橙三吉。 提交于 2019-12-08 03:54:21
问题 I know that I can use following piece of code to refresh a div: <%=Ajax.ActionLink( "Update", "Administration", new AjaxOptions { UpdateTargetId = "grid", LoadingElementId = "grid-wait" } ) %> But this creates a link; user will have to click on it to get the view refreshed. How can I make it automatic, i.e., like say if I want the grid to be refreshed after every five seconds? 回答1: Try this: <p id="CurrentDateTime"></p> <script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"><

Hide Textbox Targeted by the ColorPickerExtender

血红的双手。 提交于 2019-12-08 02:36:26
Is there a way to hide the textbox that is targeted by the colorpickerextender in the newest release of the ajax control toolkit? If you add style="display:none" to the textbox, then the color picker shows up in the top left corner of the browser window. I want it to show up near the button that is referenced in the extenders popupbuttonid. I want to hide the textbox because I don't want the user to see the color code. While I didn't hide it, I did find another way to get what I wanted. When the color is selected I call a javascript function that gets the color code from the textbox and stores

Ajax.BeginForm not working with Html.ValidationSummary

﹥>﹥吖頭↗ 提交于 2019-12-07 18:02:03
问题 I am trying to use the Ajax.BeginForm to post data to a controller. In the case of specific errors, the form should re-render and display the custom error message that was added to the ModelState. For some reason, the error message is not displaying. I am even trying the following test case which is not working, am I missing something? Edit.cshtml: @using (Ajax.BeginForm("Edit", "UserInformation", FormMethod.Post, new AjaxOptions { HttpMethod = "Post", InsertionMode = InsertionMode.Replace,

C# functions returns a value and show in webpage

人盡茶涼 提交于 2019-12-07 13:32:06
问题 I made following function in C# in my apx.cs file [WebMethod] public static string SendForm() { string message = "hello world"; return message; } And i'm trying to show the message ("hello world") when the function is called by my script in my aspx file <script> function SendForm() { var msg; msg = PageMethods.SendForm(OnSucceeded, OnFailed); function OnSucceeded() { alert(msg); } function OnFailed(error) { // Alert user to the error. alert("failed"); } } </script> <body> <form id="Form1"