|
Rank: Newbie Groups: Member
Joined: 6/19/2008 Posts: 7
|
Hi, I was trying to add a code block to the menu control so that only the selected user can see the link. I get the error "code blocks are not allowed in this context." Here is my code <eo:MenuItem Text-Html="Home"> <SubMenu> <Items> <% If CType(Session.Item("PremAuditAdmin"), Boolean) = False Then %> << Problem <eo:MenuItem NavigateUrl="AuditMaster.aspx" Text-Html="Audit Master Form"> </eo:MenuItem> <eo:MenuItem NavigateUrl="Audit.aspx" Text-Html="Audit Form"> </eo:MenuItem> <eo:MenuItem NavigateUrl="DisputeForm.aspx" Text-Html="Audit Dispute Form"> </eo:MenuItem> <eo:MenuItem NavigateUrl="comments.aspx" Text-Html="Comment Form"> </eo:MenuItem> <eo:MenuItem NavigateUrl="InfoDetails.aspx" Text-Html="Audit Information Screen"> </eo:MenuItem> <eo:MenuItem IsSeparator="True"> </eo:MenuItem> <eo:MenuItem NavigateUrl="Import.aspx" Text-Html="Import"> </eo:MenuItem> </Items>
How can i do this in asp.net (.net 2008) Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
That's normal. You will need set the MenuItem's Visible to False from code behind. It will be something like this:
Code: Visual Basic.NET
If .... Then
Menu1.Items(0).Visible = False
End If
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/19/2008 Posts: 7
|
Thanks for the quick reply. I used it like this for the SubMenu
Menu1.Items(0).SubMenu.Items(0).visible = false 'for the item in the submenu.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Yes. That's the correct way.
|
|
Rank: Member Groups: Member
Joined: 10/25/2009 Posts: 26
|
Sorry for my english!!!
I have a "eo:menu" in one User Control.
How I can access from my page code behind to my menu in a User Control, and change visible=false to my submenu ?
If I have a menu in my page is OK, but I don't understand how to refer to a menu in a user control!!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You will need to expose it as a property from your user control. For example, by adding the following code to your user control:
Code: C#
public EO.Web.Menu Menu
{
get { return Menu1; }
}
You can then access your Menu with something like "uc1.Menu". Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/25/2009 Posts: 26
|
Very thanks, I'm testing your fantastic product!!! But I'm also a newbie in c# .....another question..
I want change "Text-Html" from code
Menu2.Items[0].SubMenu.Items[2].Text = Application["DomainName"].ToString();
Error impossibile to convert 'string' in 'EO.Web.NavigationItemText
How I can resolve ?
Thanks!!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You will need to do Menu2.Items[0].SubMenu.Items[2].Text.Html = "something";
You can start a new thread (by clicking New Topic button) for a new question. That way you can have the thread title matches your question (for example, this thread's title is "Error :code blocks are not allowed in this context" and it does not match your question).
Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/25/2009 Posts: 26
|
Eheheheh I have find this solution,
Code: C#
EO.Web.MenuItem mi = new EO.Web.MenuItem();
mi.Text.Html = "something " + Application["DomainName"].ToString();
Menu2.Items[0].SubMenu.Items[2].Text = mi.Text;
but your it's more easy!!! :))) Ok next time I will open a new thread!! (sorry) Thanks!!!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Great. Glad that it works for you! Please feel free to let us know if you have any more questions.
|
|