Created
March 11, 2012 21:40
-
-
Save JakubLinhart/2018305 to your computer and use it in GitHub Desktop.
Javascript registration via ScriptManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ScriptManagerRegistration.aspx.cs" | |
Inherits="ScriptRegistrationLabyrinth.ScriptManagerRegistration" %> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<div> | |
<asp:ScriptManager runat="server" ID="ScriptManager1"> | |
</asp:ScriptManager> | |
<asp:UpdatePanel runat="server" ID="UpdatePanel1"> | |
<ContentTemplate> | |
<asp:Button runat="server" ID="Button1" Text="Do AJAX call" OnClick="Button1_Click" /> | |
<asp:Literal runat="server" ID="Literal1" /> | |
</ContentTemplate> | |
<Triggers> | |
<asp:AsyncPostBackTrigger ControlID="Button1" /> | |
</Triggers> | |
</asp:UpdatePanel> | |
</div> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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