Hi,
For some reason, the controls that are located inside the dynamically created docks are not posting back.
I am adding the whole controls as triggers:
Thank you.
For some reason, the controls that are located inside the dynamically created docks are not posting back.
I am adding the whole controls as triggers:
private
void
CreateSaveStateTrigger(RadDock dock,
string
childControlId)
{
dock.AutoPostBack =
true
;
dock.CommandsAutoPostBack =
true
;
AsyncPostBackTrigger saveStateTrigger =
new
AsyncPostBackTrigger();
saveStateTrigger.ControlID = dock.ID;
saveStateTrigger.EventName =
"DockPositionChanged"
;
UpdatePanel1.Triggers.Add(saveStateTrigger);
saveStateTrigger =
new
AsyncPostBackTrigger();
saveStateTrigger.ControlID = dock.ID;
saveStateTrigger.EventName =
"Command"
;
UpdatePanel1.Triggers.Add(saveStateTrigger);
saveStateTrigger =
new
AsyncPostBackTrigger();
saveStateTrigger.ControlID = childControlId;
UpdatePanel1.Triggers.Add(saveStateTrigger);
}
Can anyone suggest any solutions?
Thank you.
2 Answers, 1 is accepted
0

debett
Top achievements
Rank 1
answered on 06 Oct 2010, 05:01 PM
After further investigation, the update panel is unrelated to the issue. I have removed the update panel, the postback is happening, but the associated event never fires. The docks and the children controls are added dynamically on MasterPage Page_Init event.
public
partial
class
WebPanelControl : System.Web.UI.UserControl, IControl
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
public
string
CssClass
{
set
{ }
}
public
string
Skin
{
set
{
this
.RadDockLayout1.Skin = value; }
}
protected
void
Page_Init(
object
sender, EventArgs e)
{
}
public
List<Tuple<
string
,
string
,
int
>> Properties
{
set
{
var workingBee =
new
AppSettings();
foreach
(Tuple<
string
,
string
,
int
> property
in
value)
workingBee.SetProperty(
this
, property.Item1, property.Item2);
}
}
public
string
DockWidthPercentage {
set
;
get
; }
public
ControlCollection Controls
{
get
{
return
this
.Controls; }
}
protected
void
RadDockLayout1_LoadDockLayout(
object
sender, DockLayoutEventArgs e)
{
//Populate the event args with the state information. The RadDockLayout control
// will automatically move the docks according that information.
foreach
(DockState state
in
CurrentDockStates)
{
e.Positions[state.UniqueName] = state.DockZoneID;
e.Indices[state.UniqueName] = state.Index;
}
}
private
bool
_dockStateCleared =
false
;
protected
void
RadDockLayout1_SaveDockLayout(
object
sender, DockLayoutEventArgs e)
{
if
(!_dockStateCleared)
{
//Save the dock state in the session. This will enable us
// to recreate the dock in the next Page_Init.
CurrentDockStates = RadDockLayout1.GetRegisteredDocksState();
}
else
{
//the clear state button was clicked, so we refresh the page and start over.
Response.Redirect(Request.RawUrl,
false
);
}
}
private
List<DockState> CurrentDockStates
{
get
{
var _currentDockStates =
new
List<DockState>();
string
strCookieName =
this
.hfId.Value +
"Dockstates"
;
HttpCookie cookie = Request.Cookies[strCookieName];
if
(cookie ==
null
|| cookie.Value ==
""
)
{
string
possibleSettings =
new
BLLAspNetUser().GetUserSetting(strCookieName);
if
(!String.IsNullOrEmpty(possibleSettings))
_currentDockStates =
new
BLLAspNetUser().DeSerializeDockStates(possibleSettings);
else
_currentDockStates =
new
List<DockState>();
string
serializedString =
new
BLLAspNetUser().SerializeDockStates(_currentDockStates);
new
AppSettings().AddCookie(
this
.hfId.Value +
"Dockstates"
, serializedString);
}
else
{
_currentDockStates =
new
BLLAspNetUser().DeSerializeDockStates(Server.HtmlDecode(Base64Encoder.base64Decode(cookie.Value)));
}
return
_currentDockStates;
}
set
{
string
serializedString =
new
BLLAspNetUser().SerializeDockStates(value);
new
AppSettings().AddCookie(
this
.hfId.Value +
"Dockstates"
, serializedString);
new
BLLAspNetUser().SetUserSetting(
this
.hfId.Value +
"Dockstates"
, serializedString);
}
}
public
string
DockWidthInPixels {
set
{ Left.Width = Unit.Pixel(PDConvert.ToInt32(value)); } }
public
int
ControlId
{
get
{
return
PDConvert.ToInt32(
this
.hfId.Value); }
set
{
hfId.Value = value.ToString();
this
.ID = value.ToString();
}
}
public
void
AddCustomControl(IControl controlToAdd)
{
if
(!(controlToAdd
is
IDockable))
return
;
if
(CurrentDockStates.FindLast(x => x.Tag == controlToAdd.ControlId.ToString()) !=
null
)
{
RadDock dock = CreateRadDockFromState(CurrentDockStates.FindLast(x => x.Tag == controlToAdd.ControlId.ToString()));
//We will just add the RadDock control to the RadDockLayout.
// You could use any other control for that purpose, just ensure
// that it is inside the RadDockLayout control.
// The RadDockLayout control will automatically move the RadDock
// controls to their corresponding zone in the LoadDockLayout
// event (see below).
RadDockLayout1.Controls.Add(dock);
//We want to save the dock state every time a dock is moved.
CreateSaveStateTrigger(dock, (controlToAdd
as
Control).ID);
//Load the selected widget
LoadWidget(dock, controlToAdd
as
Control);
}
else
{
RadDock dock = CreateRadDock(controlToAdd.ControlId.ToString());
//find the target zone and add the new dock there
RadDockZone dz = (Left.Docks.Count > Right.Docks.Count) ? Right : Left;
dock.Tag = controlToAdd.ControlId.ToString();
dock.Title = (controlToAdd
as
IDockable).Title;
dz.Controls.Add(dock);
//Load the selected widget in the RadDock control
LoadWidget(dock, controlToAdd
as
Control);
CreateSaveStateTrigger(dock, (controlToAdd
as
Control).UniqueID);
}
}
private
void
LoadWidget(RadDock dock, Control controlToAdd)
{
dock.ContentContainer.Controls.Add(controlToAdd);
}
private
RadDock CreateRadDock(
string
dockName)
{
RadDock dock =
new
RadDock();
dock.DockMode = DockMode.Docked;
dock.UniqueName = Guid.NewGuid().ToString().Replace(
'-'
,
'a'
);
dock.ID =
string
.Format(
"RadDock{0}"
, dock.UniqueName);
dock.Title = dockName;
dock.Text =
string
.Format(
"Added at {0}"
, DateTime.Now);
dock.Width = (PDConvert.ToDouble(
this
.DockWidthPercentage) > 0) ? Unit.Percentage(PDConvert.ToDouble(
this
.DockWidthPercentage)) : dock.Width;
dock.Commands.Add(
new
DockExpandCollapseCommand());
return
dock;
}
private
RadDock CreateRadDockFromState(DockState state)
{
RadDock dock =
new
RadDock();
//dock.EnableAnimation = true;
dock.DockMode = DockMode.Docked;
dock.ID =
string
.Format(
"RadDock{0}"
, state.UniqueName);
dock.ApplyState(state);
dock.Width = (PDConvert.ToDouble(
this
.DockWidthPercentage) > 0) ? Unit.Percentage(PDConvert.ToDouble(
this
.DockWidthPercentage)) : dock.Width;
dock.Commands.Add(
new
DockExpandCollapseCommand());
return
dock;
}
private
void
CreateSaveStateTrigger(RadDock dock,
string
triggerId)
{
//Ensure that the RadDock control will initiate postback
// when its position changes on the client or any of the commands is clicked.
//Using the trigger we will "ajaxify" that postback.
dock.AutoPostBack =
true
;
dock.CommandsAutoPostBack =
true
;
//dock.DockPositionChanged += RadDock1_DockPositionChanged;
//dock.Command += RadDock1_Command;
AsyncPostBackTrigger saveStateTrigger =
new
AsyncPostBackTrigger();
saveStateTrigger.ControlID = dock.ID;
saveStateTrigger.EventName =
"DockPositionChanged"
;
UpdatePanel1.Triggers.Add(saveStateTrigger);
saveStateTrigger =
new
AsyncPostBackTrigger();
saveStateTrigger.ControlID = dock.ID;
saveStateTrigger.EventName =
"Command"
;
UpdatePanel1.Triggers.Add(saveStateTrigger);
saveStateTrigger =
new
AsyncPostBackTrigger();
saveStateTrigger.ControlID = triggerId;
UpdatePanel2.Triggers.Add(saveStateTrigger);
}
}
0
Hi,
The child controls of the RadDock will not perform postbacks, because the UpdatePanel for which the dock is an ajax trigger, will catch the request to the server, and instead of a full postback a partial one will occur.
Thank you for the sample source code. I tried to run it, but I got many errors that could not resolve. That's why I created a sample project based on the MyPortal demo. Instead of adding predefined UserControls I am adding a Button controls, and handling their Click events. The associated events are fired. Please find the project attached to the thread.
In case you still cannot resolve the issue, please open a new support ticket and send a fully working sample that demonstrates the issue and we will do our best to help you resolve the problem.
Kind regards,
Pero
the Telerik team
The child controls of the RadDock will not perform postbacks, because the UpdatePanel for which the dock is an ajax trigger, will catch the request to the server, and instead of a full postback a partial one will occur.
Thank you for the sample source code. I tried to run it, but I got many errors that could not resolve. That's why I created a sample project based on the MyPortal demo. Instead of adding predefined UserControls I am adding a Button controls, and handling their Click events. The associated events are fired. Please find the project attached to the thread.
In case you still cannot resolve the issue, please open a new support ticket and send a fully working sample that demonstrates the issue and we will do our best to help you resolve the problem.
Kind regards,
Pero
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items