This is a migrated thread and some comments may be shown as answers.

RadConfirm with grid itemdatabound

2 Answers 143 Views
Window
This is a migrated thread and some comments may be shown as answers.
usr9999
Top achievements
Rank 1
usr9999 asked on 17 Jul 2010, 06:24 AM
I have the following is my grid template column and the code behind grid databound and item command.

How can i add radconfim to the same? When user chooses yes, i want the code in item command to execute. 

<telerik:GridTemplateColumn UniqueName="Retrieve"> 

<ItemTemplate><asp:LinkButton ID="lnkRetrieve" runat="server" CausesValidation="false" CommandArgument='<%# cstr(Eval("id"))%>'  CommandName="Retrieve" Text="Retrieve"></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>

Private Sub grd_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grd.ItemDataBound If TypeOf e.Item Is GridDataItem Then
Dim llnkRetrieve As New LinkButton
  llnkRetrieve =
CType(e.Item.FindControl("lnkRetrieve"), LinkButton)
llnkRetrieve.Attributes.Add(
"onclick", "return confirm('Are you sure you want to retrieve?');")
End If 

End Sub

 

Protected 

 

Sub grd_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grd.ItemCommand
If e.CommandName = "Retrieve" Then
dim CommandArgument As String() = e.CommandArgument.ToString().Split(",")
  Session(
"ID") = CInt(CommandArgument(0))

 Respose.Redirect(

"Page.aspx", True) End If
End Sub

 

 

2 Answers, 1 is accepted

Sort by
0
usr9999
Top achievements
Rank 1
answered on 19 Jul 2010, 03:10 PM
Help Please!-
0
Accepted
Svetlina Anati
Telerik team
answered on 22 Jul 2010, 08:26 AM
Hello usr9999,

In order to get the desired result you should go through the following steps:

1) Cancel the postback of the button (this is needed because the radconfirm does not block the thread) as shown below:

llnkRetrieve.Attributes.Add("onclick", "confirm('Are you sure you want to retrieve?',  confirmCallBackFn);return false")

2) Use a client javascript callback function as shown above

3) Check the argument of in the callback and do the corresponding operation (e.g if you need to make a server call use the built-in javascript __doPostBack function as explained here: http://geekswithblogs.net/mnf/archive/2005/11/04/59081.aspx)

Detailed help article about radconfirm and how to use it is available below:

http://www.telerik.com/help/aspnet-ajax/window_dialogsconfirm.html

A sample demo is uploaded here:

http://demos.telerik.com/aspnet-ajax/window/examples/browserdialogboxes/defaultcs.aspx

I hope that my explanations and the provided resources are helpful, let me know how it goes.

Best wishes,
Svetlina
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
Tags
Window
Asked by
usr9999
Top achievements
Rank 1
Answers by
usr9999
Top achievements
Rank 1
Svetlina Anati
Telerik team
Share this question
or