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

RadButton RadWindow Confirmation ?

7 Answers 277 Views
Button
This is a migrated thread and some comments may be shown as answers.
Mihai Dinculescu
Top achievements
Rank 1
Mihai Dinculescu asked on 24 Dec 2010, 02:35 AM
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

7 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 24 Dec 2010, 08:56 AM
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.
0
Mihai Dinculescu
Top achievements
Rank 1
answered on 27 Dec 2010, 04:33 AM
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
0
Accepted
Lini
Telerik team
answered on 28 Dec 2010, 03:37 PM
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.
0
Mihai Dinculescu
Top achievements
Rank 1
answered on 28 Dec 2010, 05:04 PM
That is a good enough work around for me.

Thank you again.
0
Jonx
Top achievements
Rank 2
answered on 18 Jan 2011, 01:58 AM
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 ;)
0
Pero
Telerik team
answered on 18 Jan 2011, 04:57 PM
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.
0
Jonx
Top achievements
Rank 2
answered on 18 Jan 2011, 09:19 PM
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.
Tags
Button
Asked by
Mihai Dinculescu
Top achievements
Rank 1
Answers by
Pero
Telerik team
Mihai Dinculescu
Top achievements
Rank 1
Lini
Telerik team
Jonx
Top achievements
Rank 2
Share this question
or