Professional Web Applications Themes

Menu Item - Problem - Help! - ASP.NET Building Controls

Hi, I'm trying to customize the Menu navigation control so that the the static items have two lines. The first line will be the text (for example "About Us"), and the second line will be a short description. Also, I have a method in my class that accepts a string and returns the description required. Here is what I have on the aspx file: <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"> <DynamicItemTemplate> <%# Eval("Text") %><br /> </DynamicItemTemplate> <StaticItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("Text") %>'></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text= '<%# GetDescriptionFromTitle(Eval("Text")) %>'></asp:Label> </StaticItemTemplate> </asp:Menu> As you can see above, the Static Item's ...

  1. #1

    Default Menu Item - Problem - Help!

    Hi,

    I'm trying to customize the Menu navigation control so that the the static
    items have two lines. The first line will be the text (for example "About
    Us"), and the second line will be a short description. Also, I have a method
    in my class that accepts a string and returns the description required.

    Here is what I have on the aspx file:

    <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1">
    <DynamicItemTemplate>
    <%# Eval("Text") %><br />
    </DynamicItemTemplate>
    <StaticItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%# Eval("Text")
    %>'></asp:Label>
    <br />
    <asp:Label ID="Label2" runat="server"
    Text= '<%# GetDescriptionFromTitle(Eval("Text"))
    %>'></asp:Label>
    </StaticItemTemplate>
    </asp:Menu>

    As you can see above, the Static Item's second line (Label2) calls the
    GetDescriptionFromTitle method. However, the problem I'm facing is that I
    can't get it to accept the Eval("Text") as the parameter to this method.

    The errors I recieve are (they point to the aspx file):

    Error 1 The best overloaded method match for
    '_Default.GetDescriptionFromTitle(string)' has some invalid arguments
    Error 2 Argument '1': cannot convert from 'object' to 'string'

    Any idea what I'm doing wrong?

    Appreciate any help or pointers.

    Thanks,

    AJ

    AJ Guest

  2. #2

    Default Re: Menu Item - Problem - Help!

    On 9 Aug, 07:51, "AJ" <com> wrote: 

    Hi

    Try this:

    Text= '<%# GetDescriptionFromTitle(Eval("Text").ToString()) %>'></
    asp:Label>

    The problem is that the Eval() function returns an object. When it is
    bound to the Text property of a Control the DataBinder does the
    conversion. In your case it is being supplied as a parameter to a
    function that expects a string object so you have to do the conversion
    in your code.

    Stan Guest

  3. #3

    Default Re: Menu Item - Problem - Help!

    Hi Stan,

    Thanks for the help- that worked!

    AJ

    "Stan" <net> wrote in message
    news:googlegroups.com...
    On 9 Aug, 07:51, "AJ" <com> wrote: 

    Hi

    Try this:

    Text= '<%# GetDescriptionFromTitle(Eval("Text").ToString()) %>'></
    asp:Label>

    The problem is that the Eval() function returns an object. When it is
    bound to the Text property of a Control the DataBinder does the
    conversion. In your case it is being supplied as a parameter to a
    function that expects a string object so you have to do the conversion
    in your code.

    AJ Guest

Similar Threads

  1. create new sub-menu item....how???
    By bradfordcity in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: May 13th, 08:36 PM
  2. How get root item in menu bar
    By dragonmagik in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: May 2nd, 08:53 PM
  3. Add new Item on Pop Up Menu
    By Pierrick_Chantrel@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 0
    Last Post: April 2nd, 02:57 PM
  4. Problem in inserting Menu item
    By Bernd Alheit in forum Adobe Acrobat SDK
    Replies: 5
    Last Post: June 30th, 01:09 PM
  5. Menu Item problem with SQL query
    By singh83 in forum Dreamweaver AppDev
    Replies: 2
    Last Post: April 14th, 02:23 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139