|
Rank: Newbie Groups: Member
Joined: 8/22/2009 Posts: 6
|
Hi,
I am using a SlideMenu How can I add an asp.net checkBox control inside a subMenu in the runtime?
Thanks beforehand, batool
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, If your items are fixed, then you can use a CustomItem. CustomItem is a container that can contain any other ASP.NET controls but appears as a menu item at runtime. You would put a CustomItem in your form, place other controls in it and then points a menu item to that CustomItem. This topic has more information on how to do this (check "Regular CustomItem" section): http://doc.essentialobjects.com/library/1/menucommon/itemsandgroups/custom_item.aspxIf your items are dynamically populated from database, you can use embedded custom item or use raw HTML text as menu item text. Usually using raw HTML text is better because you will have more control. Embedded custom item is great if you just want to render something (for example, to place a Chart control inside a menu item), but it requires extra coding to get input/event back from controls inside Embedded custom items. So it probably won't work well for you. To supply raw HTML text to the custom item is very easy, you can do: SlideMenu1.Items[0].Text = "<input type='checkbox' name='cb1' /> Menu Item 1"; Note you need to give the checkbox a name. You would then use the following code to test whether "cb1" is checked:
Code: C#
if (Request.Form["cb1"] == "on")
{
//checkbox "cb1" is checked
....
}
Hope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/22/2009 Posts: 6
|
Thanks for you fast reply.
Ya my items are being populated dynamically.
I added this line code: SlideMenu1.Items[0].Text = "<input type='checkbox' name='cb1' /> Menu Item 1";
But I got this error: Cannot implicitly convert type 'string' to 'EO.Web.NavigationItemText'
So I did this: SlideMenu1.Items[0].Text.Html = "<input type='checkbox' name='cb1' /> Menu I";
But this will add the checkbox to a menu item.... How can I add it to a subMenu?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
For sub menu you would do something like this:
SlideMenu1.Items[0].SubMenu.Items[0].Text.Html = "whatever";
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/22/2009 Posts: 6
|
Again I appreciate your fast reply. Thank you very much
|
|
Rank: Newbie Groups: Member
Joined: 8/22/2009 Posts: 6
|
Hi,
I have a condition if the condition is met, the checkBox 'cb1' which was created by the HTML Text should be checked..
How can I do it?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You would just format the HTML accordingly. For example: "<input type='checkbox' checked='checked' /> whatever".
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 8/22/2009 Posts: 6
|
I couldn't do it...
I have already created this line in the page load:
SlideMenu1.Items[0].SubMenu.Items.Add("<input type='checkbox' name='pcMemoryCB' /> Memory");
Now under some button:
if (textbox1.text="Something") { //pcMemoryCB.checked = true; }
else { //pcMemoryCB.checked = false; }
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
batool wrote:I couldn't do it... That is your only option. From the slide menu point of view, it takes exactly whatever HTML you give to it. How to format that HTML according to your logic will be completely up to you. That's all there is and there is nothing more about it. Syntax like "pcMemoryCB.checked " will not work because it is just a piece of HTML snippet inside a menu item, it is not a server control. So you must figure out some way to format your slide menu text based on your logic, for example, to move Items.Add into your if statement.
|
|
Rank: Newbie Groups: Member
Joined: 8/22/2009 Posts: 6
|
Hi again,
I got that sloved thanx, however,
In page load, I created some checkboxes, like this:
Code: C#
<b> if (something.whatever== true)
{
SlideMenu1.Items[0].SubMenu.Items.Add("<input type ='checkbox' name='aCB' checked autopostback='true'/> a");
}
else
{
SlideMenu1.Items[0].SubMenu.Items.Add("<input type ='checkbox' name='bCB' autopostback='true'/> b");
}
In the slideMneu page, the user can check or uncheck the previous checkboxes, then click save button, In save button:
Code: C#
<b>if (Request.Form["aCB"] == "on")
{
something.whatever = true;<br>
}
else
{
isomething.whatever = false;<br>
}
The problem is: If in the load, aCB == false and then the user in the page checked the aCB checkbox and then click ok the checkbox will still be uncheked, though the databse was changing accordingly. So I am having a problem with the autopostback. I used the CallBackPanel and added the slideMenu as a trigger but nothing changed. Any help? Thanks beforehand
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, There is really no such thing as AutoPostBack on a regular HTML checkbox. First you imagined that there is Checked, now you imagined there is AutoPostBack. Those are only available to ASP.NET server controls. They do not exist in plain HTML. To get started, you would be doing something like <input type='checkbox' onclick='your_function()' ../>. Where your_function is a JavaScript function provided by you. That way when user clicks the checkbox, the JavaScript function will be called. How to trigger post back from that point on will be totally up to you. Once again, this has nothing to do with any other server controls. And it will not have anything to do with CallbackPanel either. You can however call eo_Callback function in your_function to trigger a callback. Please see CallbackPanel documentation for more details. We are not in a position to guide you through all the DHTML/JavaScript details, those themselves are huge topics. So if you are not familiar with those, you should seek help elsewhere. This page should give you a good idea of what's available for a plain HTML input element: http://msdn.microsoft.com/en-us/library/ms535260(VS.85).aspx If you are not familiar with JavaScript, you can find a good online tutorial here: http://www.w3schools.com/JS/default.aspBasically, because you are dealing with plain HTML here, you need to forget about everything you have when using ASP.NET server control. There is only HTML element, no server controls here. Hope this helps. Thanks
|
|