With RadAjaxManager in your MasterPage you can ajax-enable and update every single control in your application. The example below shows how this could be achieved adding the necessary AJAX settings programmatically.
This sample application contains buttons in the the master and content page. The two buttons update controls in the master and content page as well. See the code below for details:
| ASPX MasterPage |
Copy Code |
|
<rad:radajaxmanager id="RadAjaxManager1" runat="server"> <AjaxSettings> <rad:AjaxSetting AjaxControlID="btnDecrease"> <UpdatedControls> <rad:AjaxUpdatedControl ControlID="TextBox1"></rad:AjaxUpdatedControl> </UpdatedControls> </rad:AjaxSetting> </AjaxSettings> </rad:radajaxmanager> <asp:LinkButton ID="btnDecrease" runat="server" OnClick="btnDecrease_Click">Decrease</asp:LinkButton> <asp:TextBox ID="TextBox1" runat="server">0</asp:TextBox> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> |
And in the code-behind:
| C# MasterPage |
Copy Code |
|
protected void Page_Load(object sender, EventArgs e) { Label Label1 = (Label)ContentPlaceHolder1.FindControl("Label1"); RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnDecrease, Label1, null); } protected void btnDecrease_Click(object sender, EventArgs e) { Label Label1 = (Label)ContentPlaceHolder1.FindControl("Label1"); Label1.Text = Int32.Parse(Label1.Text) - 1 + ""; TextBox1.Text = Int32.Parse(TextBox1.Text) - 1 + ""; } |
| VB.NET MasterPage |
Copy Code |
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Dim Label1 As Label = CType(ContentPlaceHolder1.FindControl("Label1"), Label) RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnDecrease, Label1, Nothing) End Sub
Protected Sub btnDecrease_Click(sender As Object, e As EventArgs) Dim Label1 As Label = CType(ContentPlaceHolder1.FindControl("Label1"), Label) Label1.Text = Int32.Parse(Label1.Text) - 1 + "" TextBox1.Text = Int32.Parse(TextBox1.Text) - 1 + "" End Sub |
Content Page
| ASXP Content Page |
Copy Code |
|
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <asp:Button ID="btnIncrease" runat="server" Text="Increase" OnClick="btnIncrease_Click" /> <asp:Label ID="Label1" runat="server" Text="0"></asp:Label> </asp:Content> |
And in the code-behind:
| C# Content Page |
Copy Code |
|
protected void Page_Load(object sender, EventArgs e) { RadAjaxManager AjaxManager = (RadAjaxManager)this.Master.FindControl("RadAjaxManager1"); AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, Label1, null); TextBox TextBox1 = (TextBox)this.Master.FindControl("TextBox1"); AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, TextBox1, null); } protected void btnIncrease_Click(object sender, EventArgs e) { Label1.Text = Int32.Parse(Label1.Text) + 1 + ""; TextBox TextBox1 = (TextBox)this.Master.FindControl("TextBox1"); TextBox1.Text = Int32.Parse(TextBox1.Text) + 1 + ""; } |
| VB.NET Content Page |
Copy Code |
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Dim AjaxManager As RadAjaxManager = CType(Me.Master.FindControl("RadAjaxManager1"), RadAjaxManager) AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, Label1, Nothing) Dim TextBox1 As TextBox = CType(Me.Master.FindControl("TextBox1"), TextBox) AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, TextBox1, Nothing) End Sub
Protected Sub btnIncrease_Click(sender As Object, e As EventArgs) Label1.Text = Int32.Parse(Label1.Text) + 1 + "" Dim TextBox1 As TextBox = CType(Me.Master.FindControl("TextBox1"), TextBox) TextBox1.Text = Int32.Parse(TextBox1.Text) + 1 + "" End Sub |