So, I am unable to assign a MultiLine Message as my Confirmation Text for a Delete ImageButton.
The below code, when not REM'd out, does not throw an error but when I hit Delete, the confirmation does not appear at all and it merely Deletes the record. If I use a single Line of text, it appears and prompts for confirmation.
Not a deal breaker for me but I thought I would mention it.
Private Sub RecipientsGrid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RecipientsGrid.ItemCreated If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim DeleteBtn As GridButtonColumn = TryCast(RecipientsGrid.MasterTableView.GetColumn("DeleteOrganization"), GridButtonColumn) Dim DeleteMsg As New StringBuilder 'DeleteMsg.Append("Delete this Organization?") 'DeleteMsg.Append(ControlChars.NewLine) 'DeleteMsg.Append("Note: This will DELETE all Contacts for this Organization!") 'DeleteBtn.ConfirmText = DeleteMsg.toString DeleteBtn.ConfirmText = "DELETE ME!" End IfEnd Sub6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 11 Oct 2012, 07:01 AM
Hi Tim,
Please try the following code snippet.
C#:
Thanks,
Shinu.
Please try the following code snippet.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; GridButtonColumn DeleteBtn = RadGrid1.MasterTableView.GetColumn("DeleteOrganization") as GridButtonColumn; StringBuilder DeleteMsg = new StringBuilder(); DeleteMsg.Append("Delete this Organization?\\n"); DeleteMsg.Append("Note: This will DELETE all Contacts for this Organization!"); DeleteBtn.ConfirmText = DeleteMsg.ToString(); }}Thanks,
Shinu.
0
Tim
Top achievements
Rank 1
answered on 11 Oct 2012, 01:31 PM
Thx, I tried the code and while it does now prompt me, all the text is still on one line and it look slike the below
'Delete this Organization?\nNote: This will DELETE all Contacts for this Organization!'
'Delete this Organization?\nNote: This will DELETE all Contacts for this Organization!'
0
Greg
Top achievements
Rank 1
answered on 11 Oct 2012, 03:31 PM
Just add @ before your strings (@"text goes here\n")
0
Tim
Top achievements
Rank 1
answered on 11 Oct 2012, 03:35 PM
When I do that, VS gets upset as says Expression Expected.
I tried the Telerik Translator and it can't translate the below.
I tried the Telerik Translator and it can't translate the below.
DeleteMsg.Append(@"Delete this Organization?\\n")DeleteMsg.Append(@"Note: This will DELETE all Contacts for this Organization!")DeleteBtn.ConfirmText = DeleteMsg.ToString0
Greg
Top achievements
Rank 1
answered on 11 Oct 2012, 07:07 PM
Oh, that's right, you use Telerik control :) From your code I see that it could be done using plain Javascript confirm window. I just did it with DataTable, looped through all rows, added one column and it worked perfectly
DataSet ds = data from somehwere;StringBuilder campaignsToBreak = new StringBuilder();foreach (DataRow row in ds.Tables[1].Rows){campaignsToBreak.Append(row["CampaignName"] + @"\n");}l.Enabled = true;l.Attributes.Add("onclick", @"javascript:return confirm('All related Campaigns will have their link broken.\n\n" +campaignsToBreak + @"\nContinue?')");
0
Tim
Top achievements
Rank 1
answered on 12 Oct 2012, 06:53 PM
Ok, so I did a fair mount of testing, here's what's happening. If I put any kind of text in the ConfirmText para in the Markup, that text is what's displayed, no matter that I overwrite it from the code-behind.
Scenario 1. The below example will ALWAYS display XxX.
Scenario 2. This will always just delete the item in question, Without prompting the user. Can anyone replicate this issue?
Greg, thanks for the suggestion, I haven't tried using Javascript instead.
Scenario 1. The below example will ALWAYS display XxX.
<telerik:GridButtonColumn ConfirmText="XxX" ConfirmTitle="Delete" UniqueName="DeleteOrganization" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px" ConfirmDialogWidth="220px" HeaderStyle-Width="25" />If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim DeleteBtn As GridButtonColumn = TryCast(RecipientsGrid.MasterTableView.GetColumn("DeleteOrganization"), GridButtonColumn) Dim DeleteMsg As New StringBuilder Select Case PageName Case "Agreements.aspx" DeleteMsg.Append("Remove from this Agreement!") Case "ManageRecipients.aspx" DeleteMsg.Append("Delete Organziation, including all Contacts!!") End Select DeleteBtn.ConfirmText = DeleteMsg.ToString End IfScenario 2. This will always just delete the item in question, Without prompting the user. Can anyone replicate this issue?
<telerik:GridButtonColumn ConfirmTitle="Delete" UniqueName="DeleteOrganization" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px" ConfirmDialogWidth="220px" HeaderStyle-Width="25" />If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) Dim DeleteBtn As GridButtonColumn = TryCast(RecipientsGrid.MasterTableView.GetColumn("DeleteOrganization"), GridButtonColumn) Dim DeleteMsg As New StringBuilder Select Case PageName Case "Agreements.aspx" DeleteMsg.Append("Remove from this Agreement!") Case "ManageRecipients.aspx" DeleteMsg.Append("Delete Organziation, including all Contacts!!") End Select DeleteBtn.ConfirmText = DeleteMsg.ToStringEnd IfGreg, thanks for the suggestion, I haven't tried using Javascript instead.