What I'm doing:
1. Put two RadAjaxPanels on a page.
2. Put one Rad controls in one of these panels and a simple asp.net control in the other one.
3. Changes made in one of these panels should refresh another panel but don't touch the panel where is the change was made.
4. Do any action in the panel with RadControl - panel with asp.net control will refresh correctly.
5. Do any change with asp.net control - panel with Rad control will breaks down and doesn't fire any events anymore.
I know that I can get that behaviour from page with another methods like AjaxUpdatedControls in AjaxManager and so on, but I need to update panels like I described. It is some kind of specific application and I have to use this way to update controls on page.
Unfortunately it is not working.
Any ideas how to make it working?
1. Put two RadAjaxPanels on a page.
2. Put one Rad controls in one of these panels and a simple asp.net control in the other one.
3. Changes made in one of these panels should refresh another panel but don't touch the panel where is the change was made.
4. Do any action in the panel with RadControl - panel with asp.net control will refresh correctly.
5. Do any change with asp.net control - panel with Rad control will breaks down and doesn't fire any events anymore.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AjaxProject_1.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>Default page</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
tel:RadScriptManager
runat
=
"server"
ID
=
"Rsm1"
></
tel:RadScriptManager
>
<
tel:RadAjaxManager
runat
=
"server"
ID
=
"Ram1"
></
tel:RadAjaxManager
>
<
tel:RadScriptBlock
runat
=
"server"
>
<
script
language
=
"javascript"
>
function __doXBack(args) {
var ram = $find("<%= Ram1.ClientID %>");
if (ram) ram.ajaxRequest(args);
}
function Refresh1(sender, args) {
var value = args.getDataKeyValue("Id");
if (value) __doXBack("1|" + value);
}
function Refresh2(ddl) {
__doXBack("2|" + ddl.options[ddl.selectedIndex].value);
}
</
script
>
</
tel:RadScriptBlock
>
<
tel:RadAjaxPanel
runat
=
"server"
ID
=
"Rap1"
>
<
asp:DropDownList
runat
=
"server"
ID
=
"Rcb1"
onChange
=
"Refresh2(this)"
></
asp:DropDownList
>
</
tel:RadAjaxPanel
>
<
hr
/>
<
tel:RadAjaxPanel
runat
=
"server"
ID
=
"Rap2"
>
<
tel:RadGrid
runat
=
"server"
ID
=
"Grid1"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
<
ClientEvents
OnRowSelected
=
"Refresh1"
></
ClientEvents
>
</
ClientSettings
>
<
MasterTableView
ClientDataKeyNames
=
"Id"
></
MasterTableView
>
</
tel:RadGrid
>
</
tel:RadAjaxPanel
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Data;
using
System.Linq;
using
System.Text;
using
Telerik.Web.UI;
namespace
AjaxProject_1
{
public
partial
class
Default : System.Web.UI.Page
{
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
Ram1.AjaxRequest += Ram1OnAjaxRequest;
}
private
void
Ram1OnAjaxRequest(
object
sender, AjaxRequestEventArgs e)
{
if
(e ==
null
||
string
.IsNullOrEmpty(e.Argument))
return
;
if
(e.Argument.StartsWith(
"1|"
))
{
InitComboBox(e.Argument);
Rap1.RaisePostBackEvent(
null
);
}
if
(e.Argument.StartsWith(
"2|"
))
{
InitGrid();
Rap2.RaisePostBackEvent(
null
);
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(IsPostBack)
return
;
InitComboBox(
"0"
);
InitGrid();
}
private
void
InitComboBox(
string
id)
{
Rcb1.Items.Clear();
var list =
new
List<
string
> {id};
for
(var i = 0; i < 10; i++) list.Add(GetRandomPropertyValue());
Rcb1.DataSource = list;
Rcb1.DataBind();
}
private
static
readonly
IList<
string
> Properties =
new
[] {
"Id"
,
"Name"
};
private
void
InitGrid()
{
var data =
new
DataTable();
Array.ForEach(Properties.ToArray(), t => data.Columns.Add(
new
DataColumn(t,
typeof
(
string
))));
for
(var i = 0; i < 10; i++)
{
var row = data.NewRow();
row[
"Id"
] = i.ToString();
row[
"Name"
] = GetRandomPropertyValue();
data.Rows.Add(row);
}
Grid1.DataSource = data;
Grid1.DataBind();
}
private
static
IList<
char
> _chars;
private
static
readonly
Random Rnd =
new
Random(DateTime.Now.Millisecond);
private
static
string
GetRandomPropertyValue()
{
if
(_chars ==
null
)
{
_chars =
new
List<
char
> {
' '
,
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
};
for
(var c =
'a'
; c <=
'z'
; c++) _chars.Add(c);
for
(var c =
'A'
; c <=
'Z'
; c++) _chars.Add(c);
}
var len = Rnd.Next(10, 15);
var sb =
new
StringBuilder();
for
(var i = 0; i < len; i++) sb.Append(_chars[Rnd.Next(0, _chars.Count - 1)]);
return
sb.ToString();
}
}
}
I know that I can get that behaviour from page with another methods like AjaxUpdatedControls in AjaxManager and so on, but I need to update panels like I described. It is some kind of specific application and I have to use this way to update controls on page.
Unfortunately it is not working.
Any ideas how to make it working?