Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1740
CheckBox as a menu option and OnCheckedChanged event
posted

I am exploring the WebDataMenu and I would like to implement CheckBox as a menu option using <Templates>. I was able to get the CheckBox to display alongwith other DataMenuItem(s). However, the CheckBox is not checked when clicked. I would like to also control individual postback(s) depending on the item that is clicked and implement the server event OnCheckedChanged of the CheckBox. I would appreciate any inputs!

Here is my html markup -

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<ig:WebDataMenu ID="WebDataMenu1" runat="server" OnItemClick="WebDataMenu1_ItemClick">

 

 

<GroupSettings Orientation="Horizontal" />

 

 

<ClientEvents ItemClick="WebDataMenu1_ItemClick" />

 

 

<AutoPostBackFlags ItemClick="On" />

 

 

<Items>

 

 

<ig:DataMenuItem ImageUrl="~/Images/add.gif" Text="[Create Rings]">

 

 

</ig:DataMenuItem>

 

 

<ig:DataMenuItem ImageUrl="~/Images/add.gif" Text="[Like Sku]">

 

 

</ig:DataMenuItem>

 

 

<ig:DataMenuItem TemplateId="CheckBoxTemplate" Text="Root Item">

 

 

</ig:DataMenuItem>

 

 

</Items>

 

 

<Templates>

 

 

<ig:ItemTemplate ID="Template0" runat="server" TemplateID="CheckBoxTemplate">

 

 

<Template>

 

 

<asp:CheckBox ID="RingRollupCheckBox" runat="server" Text="Ring Rollup" TextAlign="Right" AutoPostBack="true" OnCheckedChanged="RingRollupCheckBox_CheckedChanged" />

 

 

</Template>

 

 

</ig:ItemTemplate>

 

 

</Templates>

 

 

</ig:WebDataMenu>

  • 3726
    posted

    Hi,

    I've tried your code it looks almost correct.

    You have to set Checked="false" in the <asp:CheckBox ... />

    and you have to  set ItemClick="On" to <AutoPostBackFlags ItemClick="Off" /> because you have configured the asp:CheckBox to do auto postback using AutoPostBack="true".

    The problem is that when auto postback for ItemClick is "On"  the item click event triggers a full page postback and the asp:CheckBox may have not processed the mouseclick browser event that is why it never gets checked. So I suggest to put it to Off.

    Hope this helps.

    Thanks,

    Lubomir