asp.net-ajax

Passing parameters to MVC Ajax.ActionLink

岁酱吖の 提交于 2020-01-01 05:39:22
问题 How can I send the value of the TextBox as a parameter of the ActionLink? I need to use the Html.TextBoxFor <%= Html.TextBoxFor(m => m.SomeField)%> <%= Ajax.ActionLink("Link Text", "MyAction", "MyController", new { foo = "I need here the content of the textBox, I mean the 'SomeField' value"}, new AjaxOptions{ UpdateTargetId = "updateTargetId"} )%> The Contoller/Actions looks like this: public class MyController{ public ActionResult MyAction(string foo) { /* return your content */ } } Using

removing history points from browser

倾然丶 夕夏残阳落幕 提交于 2020-01-01 05:39:08
问题 can we remove history points created in web browser. or is it possible not add history point when a sample link "some link" is clicked and url in browser changed 回答1: You cannot remove items from the browser history, but you can load a new document into the window and bypass the history with javascript. This is done with the replace() method of location objects top.location.replace( newUrl ); 回答2: Browser's history belongs to the user, not to your application (client or serverside). There is

localizing <asp:FileUpload>. IE problem

蹲街弑〆低调 提交于 2019-12-31 03:55:06
问题 what i want to do is localize <asp:FileUpload> control. as far as i understand it is not possible, because input file is being rendered by a browser and there is no way to control it from the server. so i do this: i create <asp:FileUpload> , make it transparent, create input text and input button and write function browse() { $('#fileupload').click(); } on input button onclick event. firefox and chrome does fine, IE8 - does not: it opens fileupload 's "Browse..." dialog, writes it's value to

Ajax Calendar Extender End Date

血红的双手。 提交于 2019-12-31 03:01:28
问题 I am using ajax calendar extender for 'From date' and 'To date' text box, I have to disable To date previous date or dates lesser than selected 'From date'. I can see many posts using range validation . How I can disable the dates without any message to user? 回答1: First add .dll - RJS.Web.WebControl.PopCalendar.Net.2008.dll Then add source code: <asp:TextBox ID="DepartureDate" runat="server"></asp:TextBox>     <rjs:PopCalendar ID="PopCalendar1" runat="server" Control="DepartureDate" Format=

Assign a Javascript function to AjaxOptions OnSuccess property raise an error - ASP.NET MVC

浪子不回头ぞ 提交于 2019-12-30 08:14:47
问题 I'm using the Ajax.ActionLink helper to generate a link to delete a record. This is the code: Ajax.ActionLink("Delete Image", "DeleteImage", new { id = item.Id }, new AjaxOptions { HttpMethod = "Delete", OnSuccess = "Test()" } ) I'm assign a Javascript function (Test()) to the OnSucess property because I want to do some JQuery stuff, but when I click the Delete link this error message is raised Microsoft JScript runtime error: 'b' is null or not an object in the MicrosoftAjax.js file (Line 5,

how can we prevent .exe type file upload in a website?

谁说我不能喝 提交于 2019-12-30 07:50:25
问题 Suppose we have a example.exe file. we first put that file in a new folder and then zip that folder with any zipping software, Can we prevent that zipped folder upload in a website? how can we do that? 回答1: You cannot prevent it, because you can't tell what the browser is going to submit before it submits it. All you can do is when the file arrives on the server, check the file extension - if it's an exe (or a .zip and you open it up and find an .exe) then reject it. You can use something

setInterval stops after Ajax request

落花浮王杯 提交于 2019-12-30 05:27:04
问题 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"

Dynamic Controls and Postback

六月ゝ 毕业季﹏ 提交于 2019-12-29 08:25:51
问题 I have a Panel. Now in that panel, i'm adding controls. It is getting added and displayed.The problem is when the page is posted back.I know the controls have to be binded again in the panel. But lets say if the user has entered some value in the dynamic created text box. Its is getting lost.. 回答1: I have done this before by storing the data from the controls in session. Every time you dynamically add a control, store the current data entered into the controls in session or viewstate for

“Invalid Character in Base-64 String” using ASP.NET and C#

十年热恋 提交于 2019-12-29 07:59:14
问题 I'm having this problem on posting a page. The page have a jquery ajax load called by the onchange of a dropdownlist, if I disable the onchange, the post works. "The state information is invalid for this page and might be corrupted" [FormatException: Invalid character in a Base-64 string.] System.Convert.FromBase64String(String s) +0 System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +72 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String

Prevent ASP.net __doPostback() from jQuery submit() within UpdatePanel

好久不见. 提交于 2019-12-29 01:38:09
问题 I'm trying to stop postback on form submit if my custom jQuery validation returns false. Is there any way to prevent the __doPostback() function finishing from within the submit() function? I'd assumed: $('#aspnetForm').submit(function () { return false; }); would do the trick, but apparently that's not the case: does anyone have a suggestion? The submit() function does block the postback (it won't postback if you pause at a breakpoint in firebug), but I can't seem to stop the event happening