Sys.Application.add_load() vs. $(document).ready() vs. pageLoad()

If you have control over the code-behind, you can register the JavaScript to run at startup via something like: this.Page.ClientScript.RegisterStartupScript( this.GetType(), “StartupScript”, “Sys.Application.add_load(function() { functioncall(); });”, true); As long as your component has been loaded via Sys.Application.add_init() you should be fine…

What’s the difference between $get and $find in JavaScript?

$get & $find are shortcut functions Microsoft has built into their Ajax JavaScript Library. $get is short for the standard JavaScript GetElementById function. $find is short for .Net’s findComponent() function. This is not a standard JavaScript function and is specific to Microsoft’s Ajax JavaScript library. Matt Berseth does a great write up of the differences … Read more

Disable ASP.NET Forms button after click to prevent double clicking

Here is a solution that works for the asp.net button object. On the front end, add these attributes to your asp:Button definition: <asp:Button … OnClientClick=”this.disabled=true;” UseSubmitBehavior=”false” /> In the back end, in the click event handler method call, add this code to the end (preferably in a finally block) myButton.Enabled = true;

ASP.NET MVC and Ajax, concurrent requests?

I’m expanding on Lachlan Roche’s answer, which is correct. The ASP.NET framework will “single-thread” requests that deal with Session scope (a global resource), to prevent one request from interfering with another. In WebForms I think you can use the Page directive to specify that individual pages don’t use Session and therefore don’t need to treated … Read more

Javascript error when using Messenger Connect client-side library in ASP.NET

Hey, I tried some combinations here, and the one that worked was: 1) Set the ScriptMode property of the ScriptManager to Release; 2) Load the MSN library in the CodeBehind Page_Load event, using the ClientScript class: protected void Page_Load(object sender, EventArgs e) { ClientScript.RegisterClientScriptInclude(this.GetType(), “live”, “http://js.live.net/4.0/loader.js”); } Firebug isn’t showing any error anymore, and in … Read more

How to specify javascript to run when ModalPopupExtender is shown

hmmm… I’m pretty sure that there’s a shown event for the MPE… this is off the top of my head, but I think you can add an event handler to the shown event on page_load function pageLoad() { var popup = $find(‘ModalPopupClientID’); popup.add_shown(SetFocus); } function SetFocus() { $get(‘TriggerClientId’).focus(); } i’m not sure tho if this … Read more

Full postback triggered by LinkButton inside GridView inside UpdatePanel

You need to register each and every LinkButton as an AsyncPostBackTrigger. After each row is bound in your GridView, you’ll need to search for the LinkButton and register it through code-behind as follows: protected void OrderGrid_RowDataBound(object sender, GridViewRowEventArgs e) { LinkButton lb = e.Row.FindControl(“MarkAsCompleteButton”) as LinkButton; ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb); } This also requires that ClientIDMode=”AutoID” be set … Read more

How to send a model in jQuery $.ajax() post request to MVC controller method

The simple answer (in MVC 3 onwards, maybe even 2) is you don’t have to do anything special. As long as your JSON parameters match the model, MVC is smart enough to construct a new object from the parameters you give it. The parameters that aren’t there are just defaulted. For example, the Javascript: var … Read more

ModalPopupExtender OK Button click event not firing?

Aspx <ajax:ModalPopupExtender runat=”server” ID=”modalPop” PopupControlID=”pnlpopup” TargetControlID=”btnGo” BackgroundCssClass=”modalBackground” DropShadow=”true” CancelControlID=”btnCancel” X=”470″ Y=”300″ /> //Codebehind protected void OkButton_Clicked(object sender, EventArgs e) { modalPop.Hide(); //Do something in codebehind } And don’t set the OK button as OkControlID.

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