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

add some message in radconfirm

1 Answer 77 Views
Window
This is a migrated thread and some comments may be shown as answers.
beeta one
Top achievements
Rank 1
beeta one asked on 11 Sep 2012, 12:02 PM
hii,
I want to add a "do not show again option" in RadConfirm as shown in alert.How can I achieve that?

thnks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Sep 2012, 12:17 PM
Hi Hash,

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>

Hope this helps.

Regards,
Princy.
Tags
Window
Asked by
beeta one
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or