Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ListBox > Listbox.OnClientSelectionChanging and RadWindow popup

Not answered Listbox.OnClientSelectionChanging and RadWindow popup

Feed from this thread
  • Manas avatar

    Posted on Jan 13, 2012 (permalink)

    Hello there,
    I have a listbox inside a RadToolBar as below I want to do something only if the user confirms to do it, otherwise I want to just cancel.

    What I need (Is there an example for this?):
    1. Ideally I would like to use a RadWindow.Confirm to get a response and process based on Confirm or Cancel (popup using client script only).
    2. I don't want a postback to happen if the user selects cancel on the popup.

    (with the below code the postback happens even if args.set_cancel(result) and result is the Cancel response from the window.confirm) Is it because one of the container of the listbox is causing the postback?

    Can you please help?

            <telerik:RadToolBar runat="server" ID="RadToolBar1" Width="100%" Skin="Windows7">
                <Items>
                    <telerik:RadToolBarDropDown ImageUrl="~/app_themes/default/images/Check.png">
                        <Buttons>
                            <telerik:RadToolBarButton>
                                <ItemTemplate>
                                    <telerik:RadListBox runat="server" ID="lbDoSomething" Skin="Windows7" SelectionMode="Single"
                                        OnClientSelectedIndexChanging="ConfirmDo" OnSelectedIndexChanged="lbDoSomething_OnSelectedIndexChanged"
                                        AutoPostBack="True" />
                                </ItemTemplate>
                            </telerik:RadToolBarButton>
                        </Buttons>
                    </telerik:RadToolBarDropDown>
                </Items>
            </telerik:RadToolBar>
     
     
     <script type="text/javascript">
    ....
            function ConfirmOverride(sender, args) {
                var msg = "Are you sure you want to do something?";
                var result = !window.confirm(msg);
                args.set_cancel(result);
     
            }
    </script>

    Thank you,
    Manas

    Reply

  • Bozhidar Bozhidar admin's avatar

    Posted on Jan 16, 2012 (permalink)

    Hello manas,

    I've prepared a sample page showing the basic idea of how you can achieve the functionality you describe. In the sample there is a listbox and a button. When you click the button, a prompt dialog appears, asking you to type a name. If you click ok, a new item with that name is added to the listbox. If you click cancel, nothing happens. All this is entirely done on the client. 

    To see more about the capabilities of RadWindow, you can refer to this online demo.
     
    Kind regards,
    Bozhidar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
    Attached files

    Reply

  • Manas avatar

    Posted on Jan 18, 2012 (permalink)

    Thank you Bozhidar for your reply,
    But can you please look at the code I put in my initial post there I want to show the confirmation message in the OnClientSelectedIndexChanging event handler and if the the user Cancels then do nothing (not even a postback) but if clicks OK then fo ahead with the OnSelectedIndexChanged server side event.

    The radconfirm works fine with the button the way you have in the demo link referred but it does not work with the OnClientSelectedIndexChanging event.

    The original code I posted does not work when when I changed to OnClientSelectedIndexChanging as below.

    OnClientSelectedIndexChanging="radconfirm('Are you sure you want to do something?', confirmCallBackFn, 330, 100, null,'Confirm To Do something'); return false;"

    Thanks,
    Manas

    Reply

  • Posted on Jan 19, 2012 (permalink)

    Hello,

    Try the following code snippet.
    JS:
    <script type="text/javascript">
        var oConfirm = null;
      function OnClientSelectedIndexChanging(sender, args)
       {
            oConfirm = radconfirm("sure?", callbackFn);
       }
      function callbackFn(arg)
       {
          if (arg == true)
          {
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                ajaxManager.ajaxRequestWithTarget('<%= RadListBox1.UniqueID %>', '');
          }
       }
    </script>
    C#:
    protected void RadListBox1_SelectedIndexChanged(object sender, EventArgs e)
      {
        //your code
      }

    Thanks,
    Princy.

    Reply

  • Bozhidar Bozhidar admin's avatar

    Posted on Jan 19, 2012 (permalink)

    Hi Manas,

    I've attached another page, implementing the functionality you want to achieve.
     
    Regards,
    Bozhidar
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now

    Reply

  • Manas avatar

    Posted on Jan 19, 2012 (permalink)

    Thank you Bozhidar and Princy for your help.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ListBox > Listbox.OnClientSelectionChanging and RadWindow popup