radconfirm block thread

2 posts, 0 answers
  1. G.
    G. avatar
    10 posts
    Member since:
    Oct 2011

    Posted 12 Apr 2012 Link to this post

    I have a RadComboBox which is setup as follows




    <telerik:RadComboBox ID="radcombo_1" AutoPostBack="true" runat="server" 
        onselectedindexchanged="radcombo_1_SelectedIndexChanged" OnClientSelectedIndexChanging="SelectionChange" >

    My goal is to prevent a selection change in certain scenarios.  Currently, I enforce this using good ole'
    js window.confirm as follows

    function SelectionChange(sender, eventArgs) {
        try {                
            var text = "";                
            text = sender.get_text();
            if (text != "Select") {
                var allow = false;
                allow = TheConfirm();
                if (allow == true) {
                else {
        catch (errA) {

    function TheConfirm() {
         return confirm("Change?");                     

    However, I would like to change this to utilize radconfirm with a <ConfirmTemplate>.  Yet, radconfirm does not appear to be a blocking call...

    Can anyone provide an example of how to prevent the RadComboBox selection change with a blocking radconfirm that uses a custom <ConfirmTemplate>???

    Any help would be greatly appreciated. 

  2. Marin Bratanov
    Marin Bratanov avatar
    5812 posts

    Posted 17 Apr 2012 Link to this post


    Generally blocking the execution with the RadConfirm is not possible. This is due to the fact that only native code can do this, while the RadConfirm is user JavaScript, no built-in the browser. This is explained in this help article and this online demo.

    This means that in order to use the RadConfirm in this manner you must cancel the original execution and complete the work with JavaScript. This is not always possible and in some scenarios the browser confirm() cannot be replaced with the RadConfirm.

    Nevertheless, I prepared and attached a small sample for you that asks for confirmation of the selection. I tried to base it on your logic, yet you can further modify it as needed. Note how I am using the RadComboBox's client-side API in the callback function of the RadConfirm to do the necessary work.

    As for using templates - as long as the correct buttons are present (i.e. the RadConfirm returns the expected results) - this will not be a problem. Changing the template is explained in this help article.

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