RadButton RadWindow Confirmation ?

8 posts, 2 answers
  1. Mihai Dinculescu
    Mihai Dinculescu avatar
    33 posts
    Member since:
    Nov 2009

    Posted 23 Dec 2010 Link to this post

    Hello

    I wonder if there is an easy way to get a radwindow confirmation on a RadButton like there is on RadGrid's GridButtonColumn.

    Regards
    Mihai
  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 24 Dec 2010 Link to this post

    Hi Mihai,

    For your convenience I have created a sample project that has a RadButton control in RadGrid template column, with a RadConfirm to confirm the postback. Here is the full source code:

    <%@ Page Language="C#" AutoEventWireup="true" %>
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                RadGrid1.DataSource = new string[] { "1", "2", "3", "4" };
                RadGrid1.DataBind();
            }
            protected void RadButton1_Click(object sender, EventArgs e)
            {
                Label1.Text = DateTime.Now.ToString();
     
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <script type="text/javascript">
            function OnClientClicking(sender, args)
            {
                var callBackFunction = Function.createDelegate(sender, function (argument)
                {
                    if (argument)
                    {
                        this.click();
                    }
                });
     
                var text = "Are you sure you want to submit the page?";
                radconfirm(text, callBackFunction, 300, 100, null, "Title");
                args.set_cancel(true);
            }
        </script>
        <div>
            <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            </telerik:RadWindowManager>
            <telerik:RadButton ID="RadButton1" runat="server" Text="Single Button with RadConfirm"
                OnClick="RadButton1_Click" OnClientClicking="OnClientClicking">
            </telerik:RadButton>
            <asp:Label ID="Label1" runat="server"></asp:Label>
            <telerik:RadGrid ID="RadGrid1" runat="server" Width="400px">
                <MasterTableView>
                    <Columns>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <telerik:RadButton ID="RadButton1" runat="server" Text="Button in Grid" OnClientClicking="OnClientClicking">
                                </telerik:RadButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
        </form>
    </body>
    </html>


    All the best,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mihai Dinculescu
    Mihai Dinculescu avatar
    33 posts
    Member since:
    Nov 2009

    Posted 26 Dec 2010 Link to this post

    Thank you very much. That does the trick.

    However I have one question left. Is there any way to send parameters to the OnClientClicking JS function ?

    Regards
    Mihai
  5. Answer
    Lini
    Admin
    Lini avatar
    2144 posts

    Posted 28 Dec 2010 Link to this post

    Hello,

    You can use the args parameter in the OnClientClicking(sender, args) method to get the button's command name and argument:

    args.get_commandArgument()
    args.get_commandName()

    these will get you the values of CommandName and CommandArgument you set on the RadButton control.

    Regards,
    Lini
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. Mihai Dinculescu
    Mihai Dinculescu avatar
    33 posts
    Member since:
    Nov 2009

    Posted 28 Dec 2010 Link to this post

    That is a good enough work around for me.

    Thank you again.
  7. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 17 Jan 2011 Link to this post

    Indeed... Very nice sample. This even improves my code by using the callback feature I was not aware of. Like saif, Pero, please, build a nice sample with this and integrate it somewhere in your documentation or samples... Thank you. And again, the code is terrific ;)
  8. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 18 Jan 2011 Link to this post

    Hello John,

    Indeed these are very helpful examples, and we will upload them to our Code Library. The documentation will be updated for the next release, Q1 2011.

    Best wishes,
    Pero
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  9. Jonx
    Jonx avatar
    258 posts
    Member since:
    Jul 2012

    Posted 18 Jan 2011 Link to this post

    Cool... That said, I go seldom (read never) to the code library.
    Things are not easy to find there. I go there only when someone already points to a specific sample.
    It's probably the fact that you need to download and install the thing before you know exactly what you get...
    Maybe there is a way to make the samples runable online... That would be usefull...

    Thanks anyway ;)
    John.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017