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

show message in radconfirm

1 Answer 95 Views
Window
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 21 Sep 2012, 10:56 AM
Is it possible to show a message in radconfirm like "do not show the message again" in radconfirm to prompt the user..

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Sep 2012, 11:05 AM
Hi,

Try the following code snippet to achieve your scenario.
aspx:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <ConfirmTemplate>
            <div class="rwDialogPopup radconfirm">
                <div class="rwDialogText">
                    {1}
                </div>
                <div>
                    <a onclick="$find('{0}').close(true);" class="rwPopupButton" href="javascript:void(0);">
                        <span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[OK]##</span></span></a>
                    <a onclick="$find('{0}').close(false);" class="rwPopupButton" href="javascript:void(0);">
                        <span class="rwOuterSpan"><span class="rwInnerSpan">##LOC[Cancel]##</span></span></a>
                    <br />
                    <br />
                    <br />
                    <input type="checkbox" name="{0}_checkbox" id="{0}_checkbox" />Do not show this
                    message again
                </div>
            </div>
        </ConfirmTemplate>
</telerik:RadWindowManager>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="ShowConfirm(); return false;" />
<asp:Button ID="btnClearCookie" runat="server" Text="Clear cookie" OnClientClick="ClearCookie(); return false;" />
JS:
<script type="text/javascript">
    function ShowConfirm() {
        var showConfirm = getCookie("showConfirm");
        if (!showConfirm) {
            var msg = $find("<%=RadWindowManager1.ClientID %>").radconfirm("Are you sure you want to save your changes?", confirmCallBackFn, 350, 150, null, "Save changes");
            //focus OK button - otherwise, the newly added checkbox gets the focus
            setTimeout(function () {
                msg.get_contentElement().getElementsByTagName("A")[0].focus();
            }, 0);
            msg.add_beforeClose(function () {
                var toShow = !($get(msg.get_id() + "_checkbox").checked);
                if (!toShow) setCookie("showConfirm", toShow, 365);
            });
        }
    }
  
    function confirmCallBackFn(arg) {
        //implement save logic here
  
    }
  
    function getCookie(c_name) {
        var i, x, y, ARRcookies = document.cookie.split(";");
        for (i = 0; i < ARRcookies.length; i++) {
            x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
            y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
            x = x.replace(/^\s+|\s+$/g, "");
            if (x == c_name) {
                return unescape(y);
            }
        }
    }
  
    function setCookie(c_name, value, exdays) {
        var exdate = new Date();
        exdate.setDate(exdate.getDate() + exdays);
        var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
        document.cookie = c_name + "=" + c_value;
    }
  
    function ClearCookie() {
        setCookie("showConfirm", false, -1)
    }
</script>

Thanks,
Shinu.
Tags
Window
Asked by
Tina
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or