Welcome Guest Search | Active Topics | Sign In | Register

Menu value as parameter to CallbackPanel Options
Robert
Posted: Sunday, July 8, 2007 10:41:54 AM
Rank: Member
Groups: Member

Joined: 6/29/2007
Posts: 12
Dear support,

Some questions Think
1. When populating the Menu control from database, how can I put my Primary key from the table to the "value" property for each item in the Menu?
2. Then, when in the Click event in the Menu I want to pass this value to my CallbackPanel as parameter, how can I do that?

Do you have some quick answer or some reference to check for an solution for my question?

Best Regards,
Robert
eo_support
Posted: Sunday, July 8, 2007 11:44:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,093
Hi Robert,

Both are easy. For the first one, you will want to add a "Binding", which does nothing more than map one of your data field to a menu item property. You can find more information on how to use it at here:

http://www.essentialobjects.com/ViewDoc.aspx?t=MenuCommon%2fDataBinding%2fpopulate_table.html

Scroll down and you will see "Mapping data field to item's property" section.

For the second one, if you use trigger to trigger the CallbackPanel, you don't have to do anything special. You simply handles the menu click event and use the Value property:

Code: C#
protected void Menu1_ItemClick(
    object sender, EO.Web.NavigationItemEventArgs e)
{
    string id = e.NavigationItem.Value;

    //Now you have the id that you can use
    ....
}


Note for this to work, you have to either:
1. Have view state enabled, or
2. Populate the menu event time, which means you need to remove the if condition from the following code:

Code: C#
if (Page.IsPostBack)
    PopulateMenu();


Thanks
Robert
Posted: Sunday, July 8, 2007 12:18:50 PM
Rank: Member
Groups: Member

Joined: 6/29/2007
Posts: 12
Thanks, I got the first one working.

The menu is triggered from another CallBackPanel, how do I retrive the Value property in that trigger? My app do work now but I have to store the selected Value first in a Session variabel in the Click Event and then in the other CallBackPanel Execute event I'm using this Session value.
I would really want to retrive the value directly using the e.NavigationItem.Value as an parameter to the other CallBackPanel.



eo_support
Posted: Sunday, July 8, 2007 12:32:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,093
Hi Robert,

I am not sure exactly what you mean by "The menu is triggered from another CallbackPanel"? What do you mean by "triggering a menu"? Can you explain? By default CallbackPanel works transparently and the whole thing works as if the CallbackPanel did not exist.

Thanks
Robert
Posted: Sunday, July 8, 2007 12:57:04 PM
Rank: Member
Groups: Member

Joined: 6/29/2007
Posts: 12
Okay, I have two CallBackPanels. In the first I have the Menu Control. In the Second I have added the Menu to the Triggers List. In this CallBackPanel I then want to retrive the selected Value from the Menu Click Event. The two CallBackPanels are in different Web User Controls in a MasterPage.
eo_support
Posted: Sunday, July 8, 2007 1:24:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,093
Hi Robert,

When things are in two different Web User Controls then you got to have a little bit more code. :)

The easiest way I see is to drop the Trigger and initiate the callback manually. In order to do this you will need to:

1. Set the menu's RaisesServerEvent to false. You need to set it to true in order to use the menu as a trigger, since this solution will not use trigger, you will need to set it back to false;

2. Add the following Javascript code in the first .ascx file (where your menu sits):

Code: JavaScript
function menu_item_click_handler(e, info)
{
   eo_Callback("Callback2", info.getItem().getValue());
}


Note at here you will need to replace "Callback2" to the ClientID of the second CallbackPanel.

3. Set the menu's ClientSideOnItemClick to "menu_item_click_handler". Of course you are free to change the function name. The key is this value matches the name of the function in step 2;

Now when you click the menu, it will trigger the second CallbackPanel, which triggers your server side Callback_Execute event. Inside your Execute event handler, you can use e.Parameter to retrieve the Value property since you passed it over (with the second argument) when you call eo_Callback on the client side.

Thanks
Robert
Posted: Sunday, July 8, 2007 1:49:35 PM
Rank: Member
Groups: Member

Joined: 6/29/2007
Posts: 12
Thanks!!! Applause


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.