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

radConfirm for dynamically generated buttons

3 Answers 92 Views
Window
This is a migrated thread and some comments may be shown as answers.
Art Kedzierski
Top achievements
Rank 2
Art Kedzierski asked on 30 Mar 2010, 02:55 PM
Probably a shameful noob question: I'm generating a series of buttons on page load from a SQL datasource using XSL. I'm having an issue with radConfirm and the postback. My confirm dialog shows up, but clicking OK doesn't trigger the underlying Command.

<asp:ImageButton ID="b_RemoveMod_{@mID}" runat="server"
     ImageUrl
="~\Images\12.png" AlternateText="Remove Module" CssClass="hideMe"
    
CommandName="RemoveModule"
     CommandArgument
="{@mID}"
    
OnCommand="ImageButton_onCommand"
     onClientClick
="radconfirm('Are you sure you want to delete the module and return it to inventory?',
          confirmRemoveMod, 300, 140, null, 'Confirm Module Removal');"
 /> 

I'm not sure what the first parameter of the __doPostBack should be (and heck, I'm not that confident in the second parameter, neither). If it were always a single button, I suspect the first parameter would be something like <%= Button.ClientID %>. But how do I get the ID of the clicked image button when I don't know it's ID ahead of time? There could be one, there could be 20.
function confirmRemoveMod(arg) { 
     if (arg == true) { 
          __doPostBack('''ImageButton_onCommand#RemoveModule'); 
     } 

3 Answers, 1 is accepted

Sort by
0
Art Kedzierski
Top achievements
Rank 2
answered on 30 Mar 2010, 06:40 PM
Figured part of it out:

function confirmRemoveMod(sender, arg) { 
     if (arg == true) { 
          __doPostBack(sender.get_id(), ''); 
     } 

Now I'm having issues withe the radConfirm not persisting; it blows right thru the dialog to the postback without a chance for confirm or cancel. I'll keep plugging.
0
Art Kedzierski
Top achievements
Rank 2
answered on 30 Mar 2010, 08:02 PM
I got it to pause for the confirmation dialog, but now nothing happens if you click OK. Ugh!

<asp:ImageButton ID="b_RemoveMod_{@mID}" runat="server"  
     ImageUrl="~\Images\12.png" AlternateText="Remove Module" CssClass="hideMe" 
     CommandName="RemoveModule"  
     CommandArgument="{@mID}"  
     OnCommand="ImageButton_onCommand"  
     onClientClick="radconfirm('Are you sure you want to delete the module  
          and return it to inventory?', confirmRemoveMod, 300, 140, null,  
          'Confirm Module Removal'); return false;" /> 

...and the javascript:

function confirmRemoveMod(sender, arg) { 
    if (arg) { 
        __doPostBack(sender.get_id(), ''); 
    } 

0
Tsvetie
Telerik team
answered on 02 Apr 2010, 02:34 PM
Hi Art Kedzierski,
You can use the following approach:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
<asp:Button ID="button1" runat="server" Text="Button 1"
    OnClientClick="OnClientClick(this); return false;" OnClick="OnClick" />
 
<script type="text/javascript">
    function OnClientClick(button)
    {
        radconfirm('Are you sure you want to delete the module and return it to inventory?',
            function (arg) { confirmRemoveMod(arg, button.id) }, 300, 140, null, 'Confirm Module Removal');
    };
    function confirmRemoveMod(arg,buttonID)
    {
         
        if (arg)
        {
            __doPostBack(buttonID, '');
        }
    }
</script>


All the best,
Tsvetie
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
Art Kedzierski
Top achievements
Rank 2
Answers by
Art Kedzierski
Top achievements
Rank 2
Tsvetie
Telerik team
Share this question
or