This is very common in the old Radcontrols for ASP.NET...
1. In the master page
| <form id="form1" runat="server" style="height:100%"> |
| <telerik:RadScriptManager ID="MasterRadScriptManager" runat="server" EnableScriptCombine="true"></telerik:RadScriptManager> |
| <telerik:RadAjaxManager ID="MasterRadAjaxManager" runat="server" OnAjaxRequest ="MasterRadAjaxManager_AjaxRequest" EnablePageHeadUpdate="False"> |
| <AjaxSettings/> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| </form> |
2. From the Code Behind Expose the RadAjaxManager
| public RadAjaxManager RadAjaxManager |
| { |
| get |
| { |
| return this.MasterRadAjaxManager; |
| } |
| } |
| <asp:Content ID="CLP" ContentPlaceHolderID="MCPH" runat="server"> |
| <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_OnClick" /> |
| <asp:Label ID="lblClientScript" runat="server" Text=""></asp:Label> |
| </asp:Content> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| this.Master.RadAjaxManager.AjaxSettings.AddAjaxSetting(btnSave, lblClientScript); |
| this.Master.RadAjaxManager.AjaxSettings.AddAjaxSetting(this.Master.RadAjaxManager, lblClientScript); |
| } |
| protected void btnSave_OnClick(object sender, EventArgs e) |
| { |
| lblClientScript.Text = "alert('test "+ DateTime.Now.ToLongTimeString() +"');"; |
| } |
The alert only works on the First Click but subsequent click does not fire the alert.
But if I just set the Label to some text I can see that it is refreshing the Label...again this use to work in the Old RadAjax
| protected void btnSave_OnClick(object sender, EventArgs e) |
| { |
| lblClientScript.Text = "updating "+ DateTime.Now.ToLongTimeString(); |
| } |
I also know...that i can just use ...this.Master.RadAjaxManager.ResponseScripts.Add("alert('test')"),
which works but for some instance I have to use Labels...