asp.net-ajax

How to get all ListBox items on submit action

五迷三道 提交于 2019-12-10 18:15:36
问题 How can I get all ListBox values (not just the selected items) upon submit in an asp.net MVC2 project? I'm using Ajax forms like Ajax.BeginForm("ActionName", new...) . I have already tried to select all the items in the OnBegin event of the Ajax options but not all of the ListBox items are being POSTed to the controller. 回答1: This code works for me! <script type="text/javascript"> $(document).ready(function () { $("#myForm").submit(function (e) { $("#myList option").prop("selected", "selected

PageMethods and Session

為{幸葍}努か 提交于 2019-12-10 18:04:47
问题 I have searched high and low for this solution. Any insights will be highly appreciated. The Situation: When there multiple PageMethod calls in a single page, each of the method call holds a lock on the Session object thus blocking. The PageMethod calls can be made asynchronous only with @Page directive is turned to False|ReadOnly Findings: When the Page directive is default (read/write) but the session is not used anywhere on the page, the calls are not blocked. Any read or write in to the

Adding Scripts to ScriptManager on condition

百般思念 提交于 2019-12-10 17:46:03
问题 I have a tricky scenario whereby I want to add ScriptManager scriptreference only on some conditions as follows <asp:ScriptManagerProxy ID="scriptManagerProxy1" runat="server"> <CompositeScript> <Scripts> <asp:ScriptReference path=/...." /> </Scripts> </CompositeScript> <asp:ScriptManagerProxy> I want to make this script reference only on specific condition, so I did as below <% if(xyzclass.property) { %> above code <% } %> Once I do that, I get the error as The Controls collection cannot be

GetScriptReferences does not get called

落爺英雄遲暮 提交于 2019-12-10 16:53:14
问题 I have written a Custom Control that contains the following: [assembly: System.Web.UI.WebResource("InSysControls.AssignmentLists.AssignmentLists.js", "text/javascript")] namespace InSysControls { [ToolboxData("<{0}:AssignmentLists ID='AssignmentListsID' runat=\"server\"> </{0}:AssignmentLists>"), ParseChildren(true, "Items")] public class AssignmentLists : CompositeDataBoundControl, IScriptControl, INamingContainer { #region IScriptControl Members public IEnumerable<ScriptDescriptor>

ASP.NET - Load user control using AJAX?

非 Y 不嫁゛ 提交于 2019-12-10 16:47:46
问题 I'm not sure if what I'm trying to do is possible - pretty much I just want to call a user control using AJAX and get the rendered html of the control. However, when I try and fetch the control I get the following error message: This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.ascx' may be incorrect. Please review the URL below and make sure that it is spelled correctly. Requested URL:

Change text in TextBox outside of UpdatePanel

Deadly 提交于 2019-12-10 16:42:11
问题 I have a gridview inside an UpdatePanel ( gridview is showing in a popup). On click of select button in that grid I am trying to set a textbox text in the page. But its not working ,if I remove the update panel then it will work. Please help. This is my code in aspx: <div><asp:TextBox ID="txt" runat="server /></div> <asp:UpdatePanel ID="updLendersearch" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnLenderSearch" EventName="Click" /> </Triggers>

ajax post works vs. angularjs $http does not work w/ ASP.NET MVC 4

坚强是说给别人听的谎言 提交于 2019-12-10 16:01:17
问题 I have two projects client side and server side. Client side project is pure htmljs. Server side is ASP.NET MVC 4 and Web Api. Because there are two projects I need to enable CROS functionality. I added into server's webconfig : <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type" /> </customHeaders> </httpProtocol> </system.webServer> Ajax Post version which is working: $.post(url,

Rendering partial view in ASP.Net MVC3 Razor using Ajax

倾然丶 夕夏残阳落幕 提交于 2019-12-10 15:26:26
问题 The base functionality I wish to achive is that the contents of a table are updated when a dropdownlist item is selected. This will update when the user makes a new selection and retrieve new information from the database and repopulate the table. It's also worth noting that the DropDownListFor that I want the .change() to work with is not contained within the AjaxForm but appears elsewhere on the page (admittedly in another form) To achieve this I looked at this question: Rendering partial

how to set focus on textbox after post back in asp.net

巧了我就是萌 提交于 2019-12-10 15:24:49
问题 i have a textbox in update panel. when a user type something i fetch related data from database and fill that in another textbox. My problem is that after autopostback focus on any of the textboxs is lost. How can i manage this using javascript or code because i used both like in code i used System.Web.UI.ScriptManager.GetCurrent(this).SetFocus(this.txtReference); and javascript i find one more that is <script type="text/javascript"> var postbackElement; Sys.WebForms.PageRequestManager

Should I learn Xml and Javascript before learning Ajax?

老子叫甜甜 提交于 2019-12-10 14:42:34
问题 A) Since Ajax is based on Javascript and Xml …should I learn Xml and Javascript before trying to learn Ajax? B) Even if knowing Javascript and Xml is not a must … will I be able to understand and use Ajax more efficiently if I know Javascript and Xml? 回答1: I think that having a general fundamental understanding of what AJAX is and what it is not, it far more important than knowing the ins and outs of Javascript and XML. To learn more about AJAX, click here... Rather than digging up details of