Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Using inline code

Question posted by: Bob Ross (Member) on July 23rd, 2008 08:57 AM
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:HyperLink ID="OrdersMaintenanceLink"
runat="server"
Text='<%# TranslateTag("vbeiTest") %>'
NavigateUrl="~/SE/Orders/ManageCustomerServices.aspx"
Visible='<%# CurrentOperator.IsClient = "True" %>'
CssClass="StandaloneLinks" />

But this doesn't work and I don't know why?
Plater's Avatar
Plater
Moderator
5,575 Posts
July 23rd, 2008
06:45 PM
#2

Re: Using inline code
What are you trying to accomplish with this:
Expand|Select|Wrap|Line Numbers
  1. Visible='<%# CurrentOperator.IsClient = "True" %>'


Are you trying to do a comparison?
Wouldn't that be ==?

Reply
Bob Ross's Avatar
Bob Ross
Member
119 Posts
July 24th, 2008
03:59 PM
#3

Re: Using inline code
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.

Reply
Plater's Avatar
Plater
Moderator
5,575 Posts
July 24th, 2008
04:49 PM
#4

Re: Using inline code
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 %#)
Expand|Select|Wrap|Line Numbers
  1. <div id="SWA" class="SWA" style="<%=GlobalVars.SWAStyle %>" >

Reply
Bob Ross's Avatar
Bob Ross
Member
119 Posts
July 25th, 2008
08:49 AM
#5

Re: Using inline code
No IsClient is a boolean property of the CurrentOperator object.

I tried -
Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:HyperLink ID="OrdersMaintenanceLink" 
  3. runat="server" 
  4. Text="vbeiOrdersMaintenance" 
  5. NavigateUrl="~/SE/Orders/ManageCustomerServices.aspx" Visible='<%=CurrentOperator.IsClient%>' 
  6. CssClass="StandaloneLinks" />


But to no avail.

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

Reply
Bob Ross's Avatar
Bob Ross
Member
119 Posts
July 25th, 2008
09:15 AM
#6

Re: Using inline code
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?

Reply
Plater's Avatar
Plater
Moderator
5,575 Posts
July 28th, 2008
01:32 PM
#7

Re: Using inline code
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.

Reply
Reply
Not the answer you were looking for? Post your question . . .
190,179 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top .NET Forum Contributors