Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Javascript registration via ScriptManager
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ScriptManagerRegistration.aspx.cs"
Inherits="ScriptRegistrationLabyrinth.ScriptManagerRegistration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1">
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<asp:Button runat="server" ID="Button1" Text="Do AJAX call" OnClick="Button1_Click" />
<asp:Literal runat="server" ID="Literal1" />
<asp:AsyncPostBackTrigger ControlID="Button1" />
using System;
using System.Web.UI;
namespace ScriptRegistrationLabyrinth
public partial class ScriptManagerRegistration : System.Web.UI.Page
protected void Button1_Click(object sender, EventArgs e)
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "<script>alert('Button1 clicked')</script>", false);
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", "<script>alert('client script block')</script>", false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.