Saturday, 31 March 2012

how to use RadConfirm as simple confirm

JS CODE:

<script type="text/javascript">
    window.blockConfirm = function (text, mozEvent, oWidth, oHeight, callerObj, oTitle) {
        var ev = mozEvent ? mozEvent : window.event;
        ev.cancelBubble = true;
        ev.returnValue = false;
        if (ev.stopPropagation) ev.stopPropagation();
        if (ev.preventDefault) ev.preventDefault
        var callerObj = ev.srcElement ? ev.srcElement : ev.target;
        if (callerObj) {
            var callBackFn = function (arg) {
                if (arg) {
                    callerObj["onclick"] = "";
                    if (callerObj.tagName == "A") {
                        try {
                            eval(callerObj.href)
                        }
                        catch (e) { }
                    }
                    else if (callerObj.click) {
                        callerObj.click();
                    }
                }
            }
            radconfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);
        }
        return false;
    }
</script>

HOW TO USE:

<asp:Button ID="btnDelete" OnClientClick="return blockConfirm('<br/>Are you sure you want to delete this record?<br/>&nbsp;', event, 340, 150, '', 'Delete confirm')" Text="Delete" runat="server" />



5 comments:

  1. Hi, sorry but my english is not very perfect.
    I have seen several posts of yours, very good.
    I write from Chile ...

    can you help me?

    I have an asp:LinkButton that calls a function in C#
    in ASPX:
    --------------------------------------
    "<" asp:LinkButton ID="linkdelete" runat="server" ForeColor="Green" Text="delete" OnClick="linkEliminar_Click">"

    ----------------------------------
    (I put the quotation marks that do not show me the code.)
    --------------------------------
    and in C# I have this code:
    --------------------------------
      protected void linkElimnar_Click (object sender, EventArgs e)
    {             txt_equipamiento.Text = cbb_equipamientos.Text;
                 tb_EdicionEquipo.Visible = true;
    delete(id_equipo);
    --------------------------------------

    my question is, what way I can do to make the asp:Linkbutton launch the radwindowconfirm and if I press yes, proceed to the function of C#?



    Thank you very much beforehand.

    ReplyDelete
    Replies
    1. Try with Below code snippet.

      linkdelete.Attributes.Add("onclick", "return blockConfirm('" + "Delete Text" + "

      ', event, 330, 100,'','" + "Delete Title" + "');");

      Delete
    2. Do not forget to add RadwindowManager in your page.

      Delete