Using inline code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Ross
    New Member
    • Jan 2007
    • 119

    Using inline code

    Can anyone point me in the direction of a good article or somewhere I can learn more about inline code?

    I am trying to set a links text and visibility without using the code behind file like this -
    <asp:HyperLin k ID="OrdersMaint enanceLink"
    runat="server"
    Text='<%# TranslateTag("v beiTest") %>'
    NavigateUrl="~/SE/Orders/ManageCustomerS ervices.aspx"
    Visible='<%# CurrentOperator .IsClient = "True" %>'
    CssClass="Stand aloneLinks" />

    But this doesn't work and I don't know why?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    What are you trying to accomplish with this:
    Code:
    Visible='<%# CurrentOperator.IsClient = "True" %>'
    Are you trying to do a comparison?
    Wouldn't that be ==?

    Comment

    • Bob Ross
      New Member
      • Jan 2007
      • 119

      #3
      I would like the hyperlink to be visbile or not depending on the IsClient property of the currentOperator object.

      A single '=' is used for comparison in vb.net. a double '==' throws an error.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        isClient is a string and not a boolean? If it were a boolean you could just use it's .ToString() property?


        I have used this successfully (Note the %= and not %#)
        [code=asp.net]
        <div id="SWA" class="SWA" style="<%=Globa lVars.SWAStyle %>" >
        [/code]

        Comment

        • Bob Ross
          New Member
          • Jan 2007
          • 119

          #5
          No IsClient is a boolean property of the CurrentOperator object.

          I tried -
          Code:
          		                                    
          <asp:HyperLink ID="OrdersMaintenanceLink" 
          runat="server" 
          Text="vbeiOrdersMaintenance" 
          NavigateUrl="~/SE/Orders/ManageCustomerServices.aspx" Visible='<%=CurrentOperator.IsClient%>' 
          CssClass="StandaloneLinks" />
          But to no avail.

          Anyone know any good resources I can read up on inline code?

          Comment

          • Bob Ross
            New Member
            • Jan 2007
            • 119

            #6
            According to this article it is not possible to edit a controls properties using the <% %> tags. These can only be used at the top page level (i.e outside of controls).

            There is however a work around.

            Plater how did you get it to work?

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Ah ah ah!
              "Visible" is an ASP.NET attribute, not the html attribute.
              I had mine on a plain HTML element (a DIV) so it did not try to validate attributes for the ASP.NET object.

              Comment

              Working...