Welcome Guest Search | Active Topics | Sign In | Register

Error :code blocks are not allowed in this context Options
Mark Cusson
Posted: Tuesday, March 3, 2009 10:44:52 AM
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
eo_support
Posted: Tuesday, March 3, 2009 11:08:25 AM
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!
Mark Cusson
Posted: Tuesday, March 3, 2009 12:46:30 PM
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.
eo_support
Posted: Tuesday, March 3, 2009 12:52:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Yes. That's the correct way.
tommyleo
Posted: Sunday, October 25, 2009 6:04:45 PM
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!!!
eo_support
Posted: Sunday, October 25, 2009 6:12:00 PM
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!
tommyleo
Posted: Sunday, October 25, 2009 6:39:17 PM
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!!!
eo_support
Posted: Sunday, October 25, 2009 7:17:55 PM
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!
tommyleo
Posted: Sunday, October 25, 2009 7:38:22 PM
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!!!
eo_support
Posted: Sunday, October 25, 2009 7:40:43 PM
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.


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.