ASP.NET postback with JavaScript

Here is a complete solution Entire form tag of the asp.net page <form id=”form1″ runat=”server”> <asp:LinkButton ID=”LinkButton1″ runat=”server” /> <%– included to force __doPostBack javascript function to be rendered –%> <input type=”button” id=”Button45″ name=”Button45″ onclick=”javascript:__doPostBack(‘ButtonA’,”)” value=”clicking this will run ButtonA.Click Event Handler” /><br /><br /> <input type=”button” id=”Button46″ name=”Button46″ onclick=”javascript:__doPostBack(‘ButtonB’,”)” value=”clicking this will run ButtonB.Click … Read more

How can I get the button that caused the submit from the form submit event?

I leveraged document.activeElement as sketched in this answer: How to get the focused element with jQuery? $form.on(‘submit’, function() { var $btn = $(document.activeElement); if ( /* there is an activeElement at all */ $btn.length && /* it’s a child of the form */ $form.has($btn) && /* it’s really a submit element */ $btn.is(‘button[type=”submit”], input[type=”submit”], input[type=”image”]’) … Read more

A potentially dangerous Request.Path value was detected from the client (*)

If you’re using .NET 4.0 you should be able to allow these urls via the web.config <system.web> <httpRuntime requestPathInvalidCharacters=”&lt;,&gt;,%,&amp;,:,\,?” /> </system.web> Note, I’ve just removed the asterisk (*), the original default string is: <httpRuntime requestPathInvalidCharacters=”&lt;,&gt;,*,%,&amp;,:,\,?” /> See this question for more details.

Can I specify a custom location to “search for views” in ASP.NET MVC?

You can easily extend the WebFormViewEngine to specify all the locations you want to look in: public class CustomViewEngine : WebFormViewEngine { public CustomViewEngine() { var viewLocations = new[] { “~/Views/{1}/{0}.aspx”, “~/Views/{1}/{0}.ascx”, “~/Views/Shared/{0}.aspx”, “~/Views/Shared/{0}.ascx”, “~/AnotherPath/Views/{0}.ascx” // etc }; this.PartialViewLocationFormats = viewLocations; this.ViewLocationFormats = viewLocations; } } Make sure you remember to register the view engine … Read more