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

Page_Load is firing twice in ASP.NET page

Just ran into this problem, and thought I would post an answer summarizing what I found, plus my actual issue. 1. img tags with src=”” or Image tags with ImageUrl=”” 2. Using AutoEventWireup=”true” and adding a page handler 3. Having manually added the event handler (more common for C# than VB) 4. Handling both MyBase.Load … Read more

Adding Bundles to existing ASP.NET Webforms solution

Simple solution, I had some typing errors. In the Site.Master I missed the ‘s’ from the end of bundles. Making my Site.Master look like this. <head runat=”server”> <asp:PlaceHolder runat=”server”> <%: Scripts.Render(“~/bundles/GlobalHead”) %> <%: Styles.Render(“~/Content/Global”) %> </asp:PlaceHolder> </head> <body> <%: Scripts.Render(“~/bundles/Global”) %> </body>

jQuery Validation plugin in ASP.NET Web Forms

You can checkout the rules add function, but basically here’s what you can do: jQuery(function() { // You can specify some validation options here but not rules and messages jQuery(‘form’).validate(); // Add a custom class to your name mangled input and add rules like this jQuery(‘.username’).rules(‘add’, { required: true, messages: { required: ‘Some custom message … Read more

How to fix ASP.NET error “The file ‘nnn.aspx’ has not been pre-compiled, and cannot be requested.”?

I’ve not had that error, but after a little Googling I came across this link, I’m not sure if you’ve seen it yet: http://forums.asp.net/t/956297.aspx Edit (adding the key text): This error will come when a reference is specified in web.config and deployment folder/site does not contain these dlls installed in the system or bin folder … Read more

Turning off the WebFormViewEngine when using razor?

It is perfectly OK to remove the web forms view engine if you are not using it. You can do it like: public class Global : HttpApplication { public void Application_Start() { // Clears all previously registered view engines. ViewEngines.Engines.Clear(); // Registers our Razor C# specific view engine. // This can also be registered using … Read more

How do I prevent users clicking a button twice?

If you simply disable the button then ASP.NET won’t post the form. Also you want to deal with client-side validation. Here’s my solution: <asp:Button runat=”server” ID=”btnSave” Text=”Save” OnClick=”btnSave_Click” OnClientClick=”if (!Page_ClientValidate()){ return false; } this.disabled = true; this.value=”Saving…”;” UseSubmitBehavior=”false” /> See @Dave Ward’s post for a description of UseSubmitBehavior. If you have multiple validation groups you’ll … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)