Skip to content

Latest commit

 

History

History
82 lines (63 loc) · 2.24 KB

add-radajaxmanager-programmatically.md

File metadata and controls

82 lines (63 loc) · 2.24 KB
title page_title description slug previous_url tags published type category res_type
Add the AjaxManager Programmatically
Add the AjaxManager Programmatically
Learn how to programmatically add the RadAjaxManager when working with Telerik UI for ASP.NET AJAX.
ajaxmanager/how-to/add-radajaxmanager-programmatically
ajax/radajaxmanager/how-to/add-radajaxmanager-programmatically, controls/ajaxmanager/how-to/add-radajaxmanager-programmatically
telerik, asp, net, ajax, manager, add, radajaxmanager, programmatically
true
how-to
knowledge-base
kb

Environment

Product Progress® Telerik® UI for ASP.NET AJAX AjaxManager

Description

How can I programmatically create an AjaxManager control?

Solution

To achieve the desired scenario, you need to create the AjaxManager in the Page_Init event on a later stage.

The following example demonstrates how to define the AjaxManager control.

protected void Page_Init(object sender, EventArgs e)
{
	RadAjaxManager manager = new RadAjaxManager();
	manager.ID = "RadAjaxManager1";
	this.Page.Form.Controls.Add(manager);
} 							
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
	Dim manager As New RadAjaxManager()
	manager.ID = "RadAjaxManager1"
	Me.Page.Form.Controls.Add(manager)
End Sub

Now you need to access the RadAjaxManager instance by calling the GetCurrent() static method of the RadAjaxManager class. Note that if you are creating the ScriptManager dynamically as well, you have to add it to the Page.Form.Controls collection before the RadAjaxManager control.

Server-Side

protected void Page_Load(object sender, EventArgs e)
{    
	RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
}
				
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
	Dim manager As RadAjaxManager = RadAjaxManager.GetCurrent(Page)
End Sub
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
	<script type="text/javascript">
	    function GetAjaxManager() {
	        var manager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>")
	    }
	</script>
</telerik:RadCodeBlock>