I have implemented conditional postback as follows:
Code behind
if
(
this
.Master !=
null
)
{
var ajaxManager = (RadAjaxManager)
this
.Master.FindControl(
"TelerikAjaxManager"
);
if
(ajaxManager !=
null
)
{
ajaxManager.ClientEvents.OnRequestStart +=
"ConditionalPostback"
;
}
}
Script in the content page
function ConditionalPostback(sender, eventArgs)
{
var eventTarget = eventArgs.get_eventTarget();
if (eventTarget == "<%=this.AttachmentsGrid.UniqueID %>")
{
var eventArgument = eventArgs.get_eventArgument();
if (eventArgument.indexOf("Update") > -1 ||
eventArgument.indexOf("PerformInsert") > -1)
{
eventArgs.set_enableAjax(false);
}
}
}
function GridOnCommand(sender, args)
{
if
(args.get_commandName() ==
"DownloadAttachment"
)
{
var manager = $find(
'<%= RadAjaxManager.GetCurrent(Page).ClientID %>'
);
manager.set_enableAJAX(
false
);
setTimeout(function () { manager.set_enableAJAX(
true
); }, 0);
}
}
Snippet of the RadGrid
<
telerik:RadGrid
AutoGenerateColumns
=
"False"
AutoGenerateEditColumn
=
"True"
DataSourceID
=
"AttachmentsDataSource"
ID
=
"AttachmentsGrid"
runat
=
"server"
>
<
MasterTableView
DataKeyNames
=
"Id"
DataSourceID
=
"AttachmentsDataSource"
>
<
Columns
>
<
telerik:GridAttachmentColumn
DataSourceID
=
"AttachmentDataSource"
MaxFileSize
=
"1048576"
EditFormHeaderTextFormat
=
"Upload Attachment:"
HeaderText
=
"Attachment"
HeaderTooltip
=
"Download Activity Attachment"
AttachmentDataField
=
"Attachment"
AttachmentKeyFields
=
"Id"
FileNameTextField
=
"FileName"
DataTextField
=
"FileName"
UniqueName
=
"Attachment"
>
</
telerik:GridAttachmentColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"GridOnCommand"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
The grid is contained within a TabStrip with associated pageviews.
I can upload an attachment, delete etc. but when I click a link in the tab strip, i receive two errors:
b.toUpperCase is not a function
Function.__typeName="Function";Functio...terClass("Sys.Net.WebServiceError");
Teleri...8366029 (line 6)
h is not a constructor
Function.__typeName="Function";Functio...terClass("Sys.Net.WebServiceError");
Teleri...8366029 (line 6)
Message: Object doesn't support this property or method
Line: 6
Char: 18774
Code: 0
URI: http://localhost:63311/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=TelerikScriptManager_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ae71d0a15-7471-4384-9905-78bdf2047cba%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2011.2.712.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3af9722142-3e1c-4803-86df-ecfc0d24f144%3a16e4e7cd%3aed16cbdc%3a874f8ea2%3af7645509%3a24ee1bba%3af46195d3%3a19620875%3a490a9d4e%3abd8f85e4%3a86526ba7%3ae330518b%3a1e771326%3ac8618e41%3ac172ae1e%3a9cdfc6e7%3ae4f8f289%3a8e6f0d33%3a6a6d718d%3a58366029
I copied from Firebug / IE.
After ok'ing the alerts, the page loads but with all the telerik styling and functionality in the page broken.
Any ideas what is going on?
Richard
Update (14/10/2011): The issue is caused when there is a RadComboBox within the PageView of the TabStrip.If the ConditionalPostback does not fire the first time, I'm fine but if it does, this error happens. This seems strange to me because afterwards, AJAX is back on and ConditionalPostback doesn't actually do anything when navigating through the TabStrip PageViews.
Even if I just put in a simple
<
telerik:RadComboBox runat="server" ID="test"></telerik:RadComboBox>
I get the errors.
I hate JavaScript.