I'd like to get an alert from the server inside of an AJAX call in an Update Panel but something is blocking the HttpContext.Current.Response.Write from firing on the client.

Here's a very simple aspx body content

<!-- language: lang-xml -->
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <!-- DropDownList doesn't work here -->
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
        <asp:ListItem Value="1">First</asp:ListItem>
        <asp:ListItem Value="2">Second</asp:ListItem>
    </asp:DropDownList>
</div>
</form>

And here's where I'm handling it in VB

<!-- language: lang-vb -->
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) _
        Handles DropDownList1.SelectedIndexChanged
    Dim alertMsg As String
    Dim alertScript As String
    'DO OTHER STUFF HERE
    alertMsg = String.Format("You Selected {0}", DropDownList1.SelectedItem.Text)
    alertScript = String.Format("<script type= text/javascript>alert('{0}');</script>", alertMsg)

    System.Web.HttpContext.Current.Response.Write(alertScript)

End Sub

Both times the vb code will fire, but it only scripts an alert message when called outside the the UpdatePanel, instead of inside it.

What am I doing wrong?

You have to register the script using ClientScriptManager since you are using updatepanel. Try the following code. It should work:

Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) _
    Handles DropDownList1.SelectedIndexChanged
    Dim alertMsg As String
    Dim alertScript As String
    'DO OTHER STUFF HERE
    alertMsg = String.Format("You Selected {0}", DropDownList1.SelectedItem.Text)
    alertScript = String.Format("<script type= text/javascript>alert('{0}');</script>", alertMsg)

    'register script on startup
    ClientScriptManager.RegisterStartupScript(Me.[GetType](), "Alert", alertScript);
End Sub