In some cases you need to add AJAX pairs dynamically (at runtime). You should always do this in a Page event handler, which is executed each time during the page lifecycle (Page_Load, Page_Init, Page_PreRender) so that the control could be ajaxified when the page is initially loaded.
 |
Note that you need to assure that the controls that take part in the AJAX pair are available on the page! |
The example below demonstrates how to ajaxify a Button dynamically to toggle the visibility of an Image:
| ASPX/ASCX |
Copy Code |
|
|
And in the code-behind:
| C# |
Copy Code |
|
protected void Page_Load(object sender, EventArgs e) { RadAjaxManager1.AjaxSettings.AddAjaxSetting(Button1, Panel1, null); } ... protected void Button1_Click(object sender, EventArgs e) { Image1.Visible = !Image1.Visible; } |
| VB.NET |
Copy Code |
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) RadAjaxManager1.AjaxSettings.AddAjaxSetting(Button1, Panel1, Nothing) End Sub ... Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Image1.Visible = Not Image1.Visible End Sub |