radConfirm for dynamically generated buttons

4 posts, 0 answers
  1. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 30 Mar 2010 Link to this post

    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'); 
         } 

  2. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 30 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 30 Mar 2010 Link to this post

    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(), ''); 
        } 

  5. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 02 Apr 2010 Link to this post

    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.
Back to Top