What does webform_DoPostBackWithOptions() do?

Understand that there's no such thing as "ASP.NET Controls" in the rendered HTML that the web server outputs in response to a user's request. All the ASP.NET controls do is render some HTML in a way that makes everything work as expected on the server. The Button control is emitting the "onclick" attribute in order to trigger some JavaScript that will result in the form data being posted back to the server (assuming any client side validators don't prevent it).

The reason for using this method to send the data back is, as I just mentioned, to give any client-side script a chance to run first, such as data validation controls that can check and see if any required fields are not filled out.

Basically, unless you're looking to create your own ASP.NET server controls, you don't need to worry too much about exactly what is getting emitted as the ultimate response from IIS. It's good to be familiar with what's happening (and I'm certainly not saying that you shouldn't learn exactly how server controls do their thing), but you don't have to be intimately familiar with every client-side call and parameter that ASP.NET is making in order to get started.


If you set the PostBackUrl property for the Button server control, then it means it is cross page posting and then asp.net framework instead of normal __DoPostBack() adds "WebForm_DoPostBackWithOptions". Check if you have "PostBackUrl" Property set for this button.

<asp:Button id=Send runat="server" EnableViewState="False" PostBackUrl="~/Page2.aspx"
ToolTip="Email me this report" CssClass="Button" Text="Email me this report">
</asp:Button>

If in your case you have not set the "PostBackUrl", then ASP.NET framework also does not add this by default for Button Control, so this means there has to be another control setting the OnClick attribute value probably using following sever side code -

    PostBackOptions myPostBackOptions = new PostBackOptions(this);
    myPostBackOptions.ActionUrl = "Page2.aspx";
    myPostBackOptions.AutoPostBack = false;
    myPostBackOptions.RequiresJavaScriptProtocol = true;
    myPostBackOptions.PerformValidation = true;

    // Add the client-side script to the HyperLink1 control.
    Button1.OnClientClick = Page.ClientScript.GetPostBackEventReference(myPostBackOptions);