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

RadButton Toggle in Editmode RadGrid

4 Answers 148 Views
Button
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 20 Dec 2010, 09:53 PM
Hi,
I have the following in a GridTemplateColumn
<telerik:RadButton ID="rbTest" runat="server" ButtonType="ToggleButton" Style="padding-left: 25px"
                        ToggleType="CheckBox" AutoPostBack="false" Checked='<%# Test(Eval("Test")) %>'>
                        <ToggleStates>
                            <telerik:RadButtonToggleState PrimaryIconCssClass="rbOk" />
                            <telerik:RadButtonToggleState PrimaryIconCssClass="rbCancel" />
                        </ToggleStates>
                    </telerik:RadButton>
On the ItemDataBound I am trying to add the OnClientClicked Event, I've also tried the OnClientCheckChanged. I find the control in Editemode and try the below

rbTest.Attributes.Add(

 

"OnClientCheckedChanged", "return show('0','0')");

It just doesn't seem to be firing.

Any ideas?

Thanks

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 21 Dec 2010, 07:34 AM
Hello Karl,

The following code snippet shows how to attach the client event "OnClientCheckedChanged" from server side.

C#:
GridEditFormItem editform = (GridEditFormItem)e.Item;
RadButton chk = (RadButton)editform.FindControl("rbTest");
chk.OnClientCheckedChanged = "OnClientCheckedChanged";


Regards,
Shinu.
0
Karl
Top achievements
Rank 1
answered on 21 Dec 2010, 10:07 AM
Thanks Shinu, that works, but how do I attach the following

"return show('"

 

 

+ var1 + "','" + var2 + "')"

These variables are from the grid the index of the row and the datakeyvalue. I need to passs them to the show function.

Thanks again

 

0
Accepted
Pero
Telerik team
answered on 21 Dec 2010, 03:10 PM
Hi Karl,

The easiest way would be to provide an anonymous function for the OnClientCheckedChanged property, and call your method with the parameters. Here is an example:

<%@ 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)
        {
            RadButton1.OnClientCheckedChanged = "function(button, args) { Show('Alert text from the server!'); }";
        }
 
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        function Show(text)
        {
            alert(text);
        }
    </script>
    <div>
        <telerik:RadButton ID="RadButton1" runat="server" Text="Anonymous Confirm function"
            ToggleType="CheckBox" AutoPostBack="false">
        </telerik:RadButton>
    </div>
    </form>
</body>
</html>


Greetings,
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
Karl
Top achievements
Rank 1
answered on 21 Dec 2010, 03:34 PM
Thanks, that worked
Tags
Button
Asked by
Karl
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Karl
Top achievements
Rank 1
Pero
Telerik team
Share this question
or