RadControls for ASP.NET AJAX With RadAjaxManager in your MasterPage you can ajaxify 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:
Master Page
CopyASPX
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="btnDecrease">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="TextBox1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik: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>
CopyC#
protected void Page_Load(object sender, EventArgs e)
{
Label Label1 = (Label)ContentPlaceHolder1.FindControl("Label1");
RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnDecrease, Label1);
}
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 + "";
}
CopyVB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim Label1 As Label = CType(ContentPlaceHolder1.FindControl("Label1"), Label)
RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnDecrease, Label1)
End Sub
Protected Sub btnDecrease_Click(ByVal sender As Object, ByVal 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
CopyASPX
<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>
CopyC#
protected void Page_Load(object sender, EventArgs e)
{
RadAjaxManager AjaxManager = RadAjaxManager.GetCurrent(Page);
AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, Label1);
TextBox TextBox1 = (TextBox)this.Master.FindControl("TextBox1");
AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, TextBox1);
}
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 + "";
}
CopyVB.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim AjaxManager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)
AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, Label1)
Dim TextBox1 As TextBox = CType(Me.Master.FindControl("TextBox1"), TextBox)
AjaxManager.AjaxSettings.AddAjaxSetting(btnIncrease, TextBox1)
End Sub
Protected Sub btnIncrease_Click(ByVal sender As Object, ByVal 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