<
telerik:RadWindow
runat
=
"server"
SkinID
=
"AddPersonNoteWindow"
IconUrl
=
"Images/Icons/note_add.png"
/>
background-image:
url
(
"//App_Themes/Default/Images/Icons/note_add.png"
)
args.set_cancel(
true
)
Hi guys,
I’m having a issue with a RadWindow which contains an UpdatePanel in combination with the RadWindowManager.
When the popup is added during a GET request it throws an error:
Cannot unregister UpdatePanel with ID 'test' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.
When I disable the line: “createRadWindow()” it works and the popup is visible.
Why can’t the popup be created during a GET request?
I’ve read this page: http://www.telerik.com/support/kb/aspnet-ajax/window/cannot-unregister-updatepanel-with-id-updatepanelid-since-it-was-not-registered-with-the-scriptmanager.aspx
But I use the RadWindowManager because it recreates the RadWindow from the ViewState in a postback request.
In short I have two questions:
How can I fix this issue? I Need the RadWindowManager to recreate my windows so events for controls on these dialogs work properly.
Why does the popup work when created from a postback and not from a get request.
Kind regards,
DvdBrink
Below is my sample code
aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TelerikRadWindowIssue.Default" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
asp:UpdatePanel
ID
=
"upanel"
runat
=
"server"
ChildrenAsTriggers
=
false
UpdateMode
=
Conditional
>
<
ContentTemplate
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
</
telerik:RadWindowManager
>
</
ContentTemplate
>
</
asp:UpdatePanel
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"Button"
/>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Web.UI;
using
Telerik.Web.UI;
namespace
TelerikRadWindowIssue
{
public
partial
class
Default : System.Web.UI.Page
{
protected
override
void
OnInit(EventArgs e)
{
ScriptManager1.RegisterAsyncPostBackControl(Button1);
Button1.Click +=
new
EventHandler(Button1_Click);
createRadWindow();
//With this line enabled the page crashes
//Disable and click on the button, same code, but the window opens correctly
base
.OnInit(e);
}
void
Button1_Click(
object
sender, EventArgs e)
{
createRadWindow();
upanel.Update();
}
private
void
createRadWindow()
{
TestWindow window =
new
TestWindow();
RadWindowManager1.Windows.Add(window);
}
private
class
TestWindow : RadWindow
{
public
TestWindow()
{
ContentContainer.Controls.Add(
new
UpdatePanel() { ID =
"test"
});
VisibleOnPageLoad =
true
;
Width = 150;
Height = 150;
}
}
}
}
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
class
=
"telerikControls"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
OutputCompression
=
"Disabled"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
language
=
"javascript"
type
=
"text/javascript"
>
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadSchedulerTemplate"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadSchedulerTemplate"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadSchedulerTemplate"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadButtonNewAppointment"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadSchedulerTemplate"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
</
div
>
<
div
>
<
table
width
=
"100%"
>
<
tr
>
<
td
align
=
"right"
>
<
telerik:RadButton
ID
=
"RadButtonNewAppointment"
runat
=
"server"
EnableEmbeddedSkins
=
"true"
Skin
=
"Default"
Text
=
"New"
Width
=
"60"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadScheduler
ID
=
"RadSchedulerTemplate"
runat
=
"server"
EnableDescriptionField
=
"true"
Height
=
"800"
SelectedView
=
"DayView"
DataKeyField
=
"ID"
DataSubjectField
=
"Subject"
DataStartField
=
"Start"
DataEndField
=
"End"
DataDescriptionField
=
"Description"
DataRecurrenceField
=
"RecurrenceRule"
DataRecurrenceParentKeyField
=
"RecurrenceParentID"
DataReminderField
=
"Reminder"
>
<
AdvancedForm
Modal
=
"true"
/>
<
Reminders
Enabled
=
"true"
/>
<
AppointmentContextMenuSettings
EnableDefault
=
"true"
/>
<
TimeSlotContextMenuSettings
EnableDefault
=
"true"
/>
</
telerik:RadScheduler
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
</
body
>
Private
Sub
_RadSchedulerDefault_Init(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Init
If
Not
IsPostBack
Then
GetSchedule()
End
If
End
Sub
Private
Sub
GetSchedule()
Dim
sqlCommand
As
SqlCommand =
New
SqlCommand
Try
_sqlConnection.ConnectionString =
DBConnectionManager.OpenConnection()
sqlCommand = _sqlConnection.CreateCommand
sqlCommand.CommandType = CommandType.StoredProcedure
sqlCommand.CommandText =
"S_01"
_sqlDataReader = sqlCommand.ExecuteReader
RadSchedulerTemplate.DataSource = _sqlDataReader
Catch
ex
As
Exception
DBConnectionManager.CloseConnection(_sqlConnection, _sqlDataReader)
Finally
DBConnectionManager.CloseConnection(sqlCommand)
End
Try
End
Sub
Private
Sub
RadSchedulerTemplate_DataBound(sender
As
Object
, e
As
System.EventArgs)
Handles
RadSchedulerTemplate.DataBound
DBConnectionManager.CloseConnection(_sqlConnection, _sqlDataReader)
End
Sub
Private
Sub
RadSchedulerTemplate_AppointmentInsert(sender
As
Object
, e
As
Telerik.Web.UI.AppointmentInsertEventArgs)
Handles
RadSchedulerTemplate.AppointmentInsert
Dim
dbConnection
As
SqlConnection =
New
SqlConnection
Dim
dbCommand
As
SqlCommand =
New
SqlCommand
Try
Dim
app
As
Appointment = e.Appointment
Dim
subject
As
String
= app.Subject
Dim
startDate
As
DateTime = app.Start
Dim
endDate
As
DateTime = app.
End
Dim
recurrenceRule
As
String
= app.RecurrenceRule
Dim
recurrenceParentID
As
Integer
= app.RecurrenceParentID
Dim
description
As
String
= app.Description
Dim
reminder
As
String
= app.Reminders.ToString
dbConnection = DBConnectionManager.OpenConnection()
dbCommand = dbConnection.CreateCommand
dbCommand.CommandType = CommandType.StoredProcedure
dbCommand.CommandText =
"S_02"
dbCommand.Parameters.Add(
"@Subject"
, SqlDbType.VarChar).Value = subject
dbCommand.Parameters.Add(
"@StartDate"
, SqlDbType.DateTime).Value = startDate
dbCommand.Parameters.Add(
"@EndDate"
, SqlDbType.DateTime).Value = endDate
If
Not
String
.IsNullOrEmpty(recurrenceRule)
Then
dbCommand.Parameters.Add(
"@RecurrenceRule"
, SqlDbType.VarChar).Value = recurrenceRule
End
If
If
recurrenceParentID <> 0
Then
dbCommand.Parameters.Add(
"@RecurrenceParentID"
, SqlDbType.Int).Value = recurrenceParentID
End
If
If
Not
String
.IsNullOrEmpty(description)
Then
dbCommand.Parameters.Add(
"@Description"
, SqlDbType.VarChar).Value = description
End
If
If
Not
String
.IsNullOrEmpty(reminder)
Then
dbCommand.Parameters.Add(
"@Reminder"
, SqlDbType.VarChar).Value = reminder
End
If
dbCommand.ExecuteNonQuery()
GetSchedule()
Catch
ex
As
Exception
'exception
Finally
DBConnectionManager.CloseConnection(dbConnection,
Nothing
, dbCommand)
End
Try
End
Sub
Private
Sub
RadSchedulerTemplate_NavigationCommand(sender
As
Object
, e
As
Telerik.Web.UI.SchedulerNavigationCommandEventArgs)
Handles
RadSchedulerTemplate.NavigationCommand
GetSchedule()
End
Sub
protected
void
FilesRadGrid_ItemCommand(
object
sender, Telerik.Web.UI.GridCommandEventArgs e)
{
foreach
(TreeListDataItem item
in
KnowledgeBaseRadTreeList.Items)
{
RadGrid FilesRadGrid = item.FindControl(
"FilesRadGrid"
)
as
RadGrid;
if
(e.CommandName ==
"Del"
)
{
string
[] values = e.CommandArgument.ToString().Split(
':'
);
// ID:FilePath
if
(System.IO.File.Exists(Server.MapPath(values[1])))
{
try
{
System.IO.File.Delete(Server.MapPath(values[1]));
}
catch
{ }
}
Glb_Entities.ExecuteSP(
new
object
[] {
"Usp_KnowledgeBase_Uploads_Delete"
,
"@KnowledgeBase_Uploads_ID"
, values[0]
});
FilesRadGrid.DataBind();
}
}
}
<
EditFormSettings
EditFormType
=
"Template"
PopUpSettings-Width
=
"100%"
>
<
FormTemplate
>
<
asp:Panel
ID
=
"DetailsPanel"
runat
=
"server"
DefaultButton
=
"SaveRadButton"
>
<
table
border
=
"0"
cellpadding
=
"0"
cellspacing
=
"5"
class
=
"innertable"
>
<
tr
>
<
td
>
</
td
>
<
td
class
=
"td82"
>
<
telerik:RadGrid
ID
=
"FilesRadGrid"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
DataSourceID
=
"FilesSqlDataSource"
GridLines
=
"None"
Width
=
"530px"
Visible
=
"false"
OnItemCommand
=
"FilesRadGrid_ItemCommand"
>
<
MasterTableView
DataKeyNames
=
"KnowledgeBase_Uploads_ID"
DataSourceID
=
"FilesSqlDataSource"
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
/>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"FileName"
FilterControlAltText
=
"Filter FileName column"
HeaderText
=
"File Name"
SortExpression
=
"FileName"
UniqueName
=
"FileName"
FilterControlWidth
=
"80%"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
/>
<
ItemStyle
HorizontalAlign
=
"Left"
Font-Size
=
"11px"
Font-Names
=
"Arial"
VerticalAlign
=
"Middle"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Action"
AllowFiltering
=
"false"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"DeleteImageButton"
runat
=
"server"
ToolTip
=
"Delete"
CommandName
=
"Del"
ImageUrl
=
"~/App_Themes/ELPISCMS/images/delete.png"
OnClientClick
=
"if (!confirm('Are you sure, you want to delete this record?')) {return false;}"
CommandArgument='<%# Eval("KnowledgeBase_Uploads_ID") +":"+ Eval("KnowledgeBase_Uploads_ID") %>' />
</
ItemTemplate
>
<
ItemStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
Width
=
"50px"
/>
<
HeaderStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
Width
=
"50px"
/>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
/>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
/>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
/>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"FilesSqlDataSource"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:elpis_cmsConnectionString %>"
SelectCommand="Usp_KnowledgeBase_Uploads_Select" SelectCommandType="StoredProcedure">
<
SelectParameters
>
<
asp:ControlParameter
ConvertEmptyStringToNull
=
"true"
ControlID
=
"KnowledgeBaseIDHiddenField"
DbType
=
"Int32"
Name
=
"KnowledgeBase_ID"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"td18"
>
Status :
</
td
>
<
td
class
=
"td82"
>
<
asp:RadioButton
ID
=
"ActiveRadioButton"
runat
=
"server"
CssClass
=
"radiobutton"
Checked
=
"true"
GroupName
=
"ActiveInactive"
/>Active
<
asp:RadioButton
ID
=
"InactiveRadioButton"
runat
=
"server"
CssClass
=
"radiobutton"
GroupName
=
"ActiveInactive"
/>Inactive
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
class
=
"td82"
>
<
telerik:RadButton
ID
=
"SaveRadButton"
runat
=
"server"
Text='<%# (Container is TreeListEditFormInsertItem) ? "Save" : "Update" %>'
CausesValidation="true" CommandName='<%# (Container is TreeListEditFormInsertItem) ? "PerformInsert" : "Update" %>'
ValidationGroup="KnowledgeBaseValidationGroup" Width="80px">
<
Icon
PrimaryIconUrl
=
"~/App_Themes/ELPISCMS/images/save2.png"
PrimaryIconLeft
=
"5"
PrimaryIconTop
=
"3"
/>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"CancelRadButton"
runat
=
"server"
Text
=
"Cancel"
CommandName
=
"Cancel"
CausesValidation
=
"false"
Width
=
"80px"
>
<
Icon
PrimaryIconUrl
=
"~/App_Themes/ELPISCMS/images/cancel2.png"
PrimaryIconLeft
=
"5"
PrimaryIconTop
=
"3"
/>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
</
FormTemplate
>
</
EditFormSettings
>
We have a RadGrid with some telerik:GridTemplateColumns. We get a datasource and bind the grid. For first page grid behavour is consistent. But after page change, other columns in grid gets new values but itemtemplate columns persist the values from first page.
Grid Design Code :
<
telerik:RadGrid ID="rgvTest" runat="server" AllowFilteringByColumn="false"
AllowPaging="True" AllowSorting="True" MasterTableView-ShowHeadersWhenNoRecords="false"
AllowCustomPaging="false" AutoGenerateDeleteColumn="false" AllowMultiRowSelection="true"
AutoGenerateEditColumn="false" GridLines="None" ShowGroupPanel="True" OnItemDataBound="rgvTest_ItemDataBound"
OnPageIndexChanged="rgvTest_PageIndexChanged" OnSortCommand="rgvTest_SortCommand"
ClientSettings-ClientEvents-OnRowDblClick="GridRowDoubleclick" >
<
Columns>
<telerik:GridTemplateColumn HeaderImageUrl="../Images/priority_icon.png" UniqueName="Priority1"
HeaderTooltip="Priority">
<ItemStyle Width="20px" Wrap="false" />
<HeaderStyle Width="20px" Wrap="false" />
<ItemTemplate>
<asp:Image ID="PriorityImage" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Column>
Considering page size is set to 10.
After debugging , i got that OnItemdataBound event is called for first 10 records on load.
And after page change, it is called for 20 times but insted for 20 record of first page and second page, it is called twice for first 10 records... Strange but true.
If anyone has any idea abot this please help me out.