One of the many areas of ASP.NET where I could use to have more expertise is that of injecting client script into pages. I've often done it manually (e.g, by using control.Attributes.Add), but the Page class also has a number of methods for injecting client script in a more structured away. These include:
The problem -- a problem -- is that the documentation for these methods is, mmm, not so great. Moreover, the documentation lacks an overview that pulls all these together and provides a nice chart telling you under what circumstances to use which, um, method (member or approach). A task for the Whidbey docs.
There are some articles on this already available, which are somewhat helpful:Anyway, based on what I read, I thought I'd play around a little. RegisterOnSubmitStatement sounded interesting, so I experimented to see if I could write the minimal-case example of confirming that you want to submit a page. Here's what I came up with:
<%@ Page Language="VB" %>
Dim script As String = "return DoConfirm();"
Sub Button1_Click(sender As Object, e As EventArgs)
Label1.Text = "Posted @ " & DateTime.Now.ToString()
return confirm("Do you want to submit?");
<asp:Label id="Label1" runat="server">Label</asp:Label>
<asp:Button id="Button1" onclick="Button1_Click" runat="server"