Checkbox CheckedChanged event in a template

3 posts, 1 answers
  1. Joaquín
    Joaquín avatar
    27 posts
    Member since:
    Jan 2012

    Posted 21 Mar 2012 Link to this post

    Hello,

    I have a menu with an item template. Inside it there is a checkbox. I'd like to postback when the checkbox checked state is changed, but cant get it to work. Here is the code:

    <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="True" EnableShadows="True"
                    Skin="Office2007" >
                    <Items>
                        <telerik:RadMenuItem runat="server" Text="Profile" PostBack="False" >
                            <Items>
                                <telerik:RadMenuItem runat="server" Text="Save current selections as default" Font-Size="12px">
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem runat="server" Text="Load default selections" Font-Size="12px">
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem runat="server" IsSeparator="True" Text="Child RadMenuItem 3" Font-Size="12px"
                                    PostBack="False">
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem Text="AlwaysLoad" >
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkAlwaysLoad" runat="server" Text=" Always load default selections" Font-Size="11px" />
                                    </ItemTemplate>
                                </telerik:RadMenuItem>
                                <telerik:RadMenuItem Text="AlwaysSave" >
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkAlwaysSave" runat="server" Text=" Always save current selections" Font-Size="11px" />
                                    </ItemTemplate>
                                </telerik:RadMenuItem>
                            </Items>
                        </telerik:RadMenuItem>
                    </Items>
                </telerik:RadMenu>



    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
     
            Dim alwaysSave As CheckBox = RadMenu1.FindItemByText("AlwaysSave").FindControl("chkAlwaysSave")
            AddHandler alwaysSave.CheckedChanged, AddressOf alwaysSave_CheckedChanged



    Protected Sub alwaysSave_CheckedChanged(sender As Object, e As System.EventArgs)
            Profile.CreateProject.AlwaysSave = sender.Checked
        End Sub

    But the event is never fired. Can you please tell me what am I doing wrong?

    Thank you very much.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Mar 2012 Link to this post

    Hello,

    Please set the AutoPostBack property of chkAlwaysSave CheckBox to true.
    ASPX:
    <asp:CheckBox ID="chkAlwaysSave" runat="server" Text=" Always save current selections" AutoPostBack="true" Font-Size="11px" />

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joaquín
    Joaquín avatar
    27 posts
    Member since:
    Jan 2012

    Posted 22 Mar 2012 Link to this post

    I'm stoopid. Sorry for wasting your time, Princy, and thank you for making a blind to open his eyes (this is a saying here; don't know if there is a translation in the States, but I think you'll get it).
Back to Top