473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

code within control declaration

I'd like to have a control visible/not visible based on some value eg:
<asp:Button ID="Button1" runat="server" Text="Change" Visible=<%
Membership.GetUser("david").IsOnline >% />

doesn't seem to work, do I maybe have to set the Visible property from
codebehind?
Nov 19 '05 #1
2 841
Daves:

(a) you COULD use <%= instead of just <% which would solve your problem
(b) you SHOULD use codebehind because it's far easier to read/maintain...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Daves" <db****@simnet.is> wrote in message
news:On**************@TK2MSFTNGP14.phx.gbl...
I'd like to have a control visible/not visible based on some value eg:
<asp:Button ID="Button1" runat="server" Text="Change" Visible=<%
Membership.GetUser("david").IsOnline >% />

doesn't seem to work, do I maybe have to set the Visible property from
codebehind?

Nov 19 '05 #2
On Mon, 11 Apr 2005 12:51:02 -0500, Daves <db****@simnet.is> wrote:
I'd like to have a control visible/not visible based on some value eg:
<asp:Button ID="Button1" runat="server" Text="Change" Visible=<%
Membership.GetUser("david").IsOnline >% />

doesn't seem to work, do I maybe have to set the Visible property from
codebehind?


Looks like a few typos, I assume you're trying to databind here; Visible
attribute should look like:

Visible='<%# Membership.GetUser("david").IsOnline %>'

and make sure you call .DataBind() on the textbox at the appropriate
time...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
2
by: Shailaindra Sharma | last post by:
The Following code generates Error while compiling: Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum,...
136
by: Merrill & Michele | last post by:
A derangement is a mapping of a set onto itself leaving no element fixed. I realized that that was what I was programming when I was asked to randomly determine who buys presents for whom this...
1
by: Jun Avendano | last post by:
Hi, Is there a way to prevent automatic declaration of a custom control in the code-behind of an asp.net page? Thanks, Jun
8
by: Brett Robichaud | last post by:
I understand how code-behind can handle events for a page, but can I call a code-behind method from within a <script> tag in my ASP.Net page, or can I only call methods defined in other <script>...
6
by: William Parker | last post by:
I have a web control I made called header.ascx. It has its own properties and methods I defined. But I cannot figure out how to access this control from my code behind page. I can create the...
15
by: CR | last post by:
I've noticed that the trend these days is to declare variables in the middle of code instead of at the top. What is the advantage of this? It seems like it makes it hard to reuse variables. Here...
3
by: Mark | last post by:
Hi All, I have wrote a sub to record events from within the database. A lot of these events are errors. The sub has the module name and function/sub name passed to it to record to the table. My...
3
by: Mike P | last post by:
I have a HTML menu that I want to add some C# code around which will include a variable declaration and an if statement. How do I add this code within my HTML? *If statement here, if true then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.