Hi,
I am trying to callback with image button inside radgrid <detailtables>. Server side code is executed but the control is not returned to javascript function that is receiving the results.
Can you help me?!
protected
void
Page_Load(
object
sender, EventArgs e)
{
ClientScriptManager cm = Page.ClientScript;
cbReference = cm.GetCallbackEventReference(
this
,
"arg"
,
"ReceiveServerData"
,
""
,
"errorData"
,
false
);
String callbackScript =
"function CallServer(arg, context) {"
+
cbReference +
"; WebForm_InitCallback(); }"
;
cm.RegisterClientScriptBlock(
this
.GetType(),
"CallServer"
, callbackScript,
true
);
}
public
void
RaiseCallbackEvent(String eventArgument)
{
//fetch some data
}
public
string
GetCallbackResult()
{
return
strJSON;
}
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
EnableAJAX
=
"False"
HorizontalAlign
=
"NotSet"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
CellSpacing
=
"0"
GridLines
=
"None"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
DataSourceID
=
"SqlDataSource1"
ShowGroupPanel
=
"True"
AllowSorting
=
"True"
Skin
=
"Office2010Blue"
Height
=
"100%"
Width
=
"100%"
GroupLoadMode
=
"Server"
OnItemInserted
=
"RadGrid1_ItemInserted"
OnInsertCommand
=
"RadGrid1_InsertCommand"
OnItemCommand
=
"RadGrid1_ItemCommand"
onitemdatabound
=
"RadGrid1_ItemDataBound"
>
...
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Detail"
DataKeyNames
=
"ExamID"
AllowSorting
=
"false"
DataSourceID
=
"SqlDataSource2"
Width
=
"100%"
PageSize
=
"10"
ShowHeader
=
"False"
RetrieveAllDataFields
=
"false"
runat
=
"server"
CommandItemDisplay
=
"Top"
EditMode
=
"EditForms"
NoDetailRecordsText
=
"No records to display."
AutoGenerateColumns
=
"false"
AllowAutomaticUpdates
=
"true"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"false"
CommandItemSettings-AddNewRecordText
=
"New exam"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"CertificationID"
MasterKeyField
=
"CertificationID"
/>
</
ParentTableRelation
>
<
AlternatingItemStyle
/>
<
NoRecordsTemplate
>
<
asp:Label
runat
=
"server"
Text
=
"No records."
></
asp:Label
>
</
NoRecordsTemplate
>
<
EditFormSettings
ColumnNumber
=
"1"
CaptionDataField
=
"Exam"
InsertCaption
=
"New exam"
CaptionFormatString
=
"Edit properties of exam {0}"
>
<
FormTableItemStyle
Width
=
"100%"
Height
=
"29px"
/>
<
FormTableStyle
GridLines
=
"None"
CellPadding
=
"2"
CellSpacing
=
"0"
/>
<
FormStyle
Width
=
"100%"
BackColor
=
"#eef2ea"
/>
<
EditColumn
ButtonType
=
"ImageButton"
CancelText
=
"Cancel"
UpdateText
=
"Update"
InsertText
=
"Add"
/>
</
EditFormSettings
>
<
CommandItemSettings
AddNewRecordText
=
"New exam"
ExportToPdfText
=
"Export to PDF"
/>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"LinkButton"
ItemStyle-Width
=
"50px"
UniqueName
=
"EditCommandColumn"
>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete2"
UniqueName
=
"DeleteColumn"
>
</
telerik:GridButtonColumn
>
<
telerik:GridTemplateColumn
></
telerik:GridTemplateColumn
>
<%--<
telerik:GridBoundColumn
DataField
=
"CertificationID"
FilterControlAltText
=
"Filter exam number column"
HeaderText
=
"Certification ID"
UniqueName
=
"CertificationID"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"ExamID"
FilterControlAltText
=
"Filter exam number column"
HeaderText
=
"Exam ID"
UniqueName
=
"ExamID"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>--%>
<
telerik:GridBoundColumn
DataField
=
"Exam"
DataType
=
"System.String"
FilterControlAltText
=
"Filter exam number column"
HeaderText
=
"Exam number"
UniqueName
=
"Exam"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
FilterControlAltText
=
"Filter Name column"
HeaderText
=
"Exam name"
UniqueName
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"ArrowColumn"
>
<
ItemTemplate
>
dsds
<
asp:ImageButton
BorderStyle
=
"Solid"
ID
=
"ImageButton1"
AlternateText
=
"Delete4"
runat
=
"server"
CommandName
=
"Delete4"
ImageUrl
=
"~/_layouts/Images/Delete.GIF"
OnClientClick
=
"ConfirmDelete;"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"ArrowColumn2"
>
<
ItemTemplate
>
<
input
type
=
"button"
id
=
"buttondel"
value
=
"Callback"
runat
=
"server"
onclick
=
"CallServer(1,1);"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
function
ReceiveServerData(arg, context) {
var
c = eval(arg);
for
(
var
i
in
c) {
$(
"#ResultsTable2 tr:last"
).after(
"<tr><td>"
+ c[i][0] +
" - "
+ c[i][1] +
"</td><td>"
);
}
}
Solved:
Problem was in String callbackScript =
"function CallServer(arg, context) {"
+
cbReference +
"; WebForm_InitCallback(); }"
;
called after cbreference and not clearing
__theFormPostData and __theFormPostCollection viewstate variables.
Solution that worked for me:
ClientScriptManager cm = Page.ClientScript;
cbReference = cm.GetCallbackEventReference(
this
,
"arg"
,
"ReceiveServerData"
,
""
,
"errorData"
,
false
);
String callbackScript =
"function CallServer(arg, context) { __theFormPostData = ''; __theFormPostCollection = new Array(); WebForm_InitCallback();"
+
cbReference +
"; }"
;