IE10 SCRIPT5009: ‘__doPostBack’ is undefined

There is apparently a bug in the browser definition files that shipped with .NET 2.0 and .NET 4. The definition files do not cater for IE10 as a browser version and hence defaults to a default definition which doesn’t support JavaScript. Scott Hanselman has a very detailed writeup about this issue here: http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx Scott proposes … Read more

How to maintain scroll position on autopostback?

I’ve recently looked for this as well. Came up with a load of Javascript to be inserted until I found the following: At the top of your .aspx codefile, insert the following: MaintainScrollPositionOnPostback=”true” so the very first sentence in your .aspx starts <%@ Page Language=”C#” MaintainScrollPositionOnPostback=”true” AutoEventWireup=”true” CodeBehind=”Default.aspx.cs” This works just fine for me without … Read more

Retrieving data from a POST method in ASP.NET

The data from the request (content, inputs, files, querystring values) is all on this object HttpContext.Current.Request To read the posted content StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream); string requestFromPost = reader.ReadToEnd(); To navigate through the all inputs foreach (string key in HttpContext.Current.Request.Form.AllKeys) { string value = HttpContext.Current.Request.Form[key]; }

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

Which control caused the postback?

You can use this method to get the control that caused the postback: /// <summary> /// Retrieves the control that caused the postback. /// </summary> /// <param name=”page”></param> /// <returns></returns> private Control GetControlThatCausedPostBack(Page page) { //initialize a control and set it to null Control ctrl = null; //get the event target name and find the … Read more

What is the difference between Page.IsPostBack and Page.IsCallBack?

Page.IsCallBack It is getting a value indicating whether the page request is the result of a call back. Its a special postback, so a round-trip always occurs; however, unlike the classic postback, the script callback doesn’t redraw the whole page. ViewState is not updated during a callback, it is for postback. Page.IsPostBack Checks whether the … Read more

Confirm postback OnClientClick button ASP.NET

Try this: <asp:Button runat=”server” ID=”btnUserDelete” Text=”Delete” CssClass=”GreenLightButton” OnClick=”BtnUserDelete_Click” OnClientClick=”if ( ! UserDeleteConfirmation()) return false;” meta:resourcekey=”BtnUserDeleteResource1″ /> This way the “return” is only executed when the user clicks “cancel” and not when he clicks “ok”. By the way, you can shorten the UserDeleteConfirmation function to: function UserDeleteConfirmation() { return confirm(“Are you sure you want to delete … Read more

OnclientClick and OnClick is not working at the same time?

From this article on web.archive.org : The trick is to use the OnClientClick and UseSubmitBehavior properties of the button control. There are other methods, involving code on the server side to add attributes, but I think the simplicity of doing it this way is much more attractive: <asp:Button runat=”server” ID=”BtnSubmit” OnClientClick=”this.disabled = true; this.value=”Submitting…”;” UseSubmitBehavior=”false” … Read more