Setting Visible attribute in a web form

Hi - how can I set the Visible property of a Hyperlink programmatically in a web form? The link still shows with the following:

 

<asp:HyperLink ID="hlLink" runat="server" Text="Link" NavigateUrl="~/default.aspx" Visible='<%# 1 == 0 %>' />
 
0
dvans
5/5/2008 7:09:29 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

5 Replies
475 Views

Similar Articles

[PageSpeed] 25

Is your HyperLink within a bindable container such as a GridView? If not, try calling Page.DataBind() and see if it doesn't work.


Thanks, Ed

Microsoft MVP - ASP/ASP.NET

0
ecbruck
5/5/2008 7:13:29 PM

If you use a databinding expression, you'd need to call hlLink.DataBind() or databind some ancestor control (DataGrid, GridView etc)

But you could just use a boolean expression to set it Visible="False" in normal case. Programmatically you can set it with

[VB.NET]
hlLink.Visible = True|False 'Choose either one

[C#]
hlLink.Visible = true|false; //Choose either one


Thanks,

Teemu Keiski
Finland, EU
0
joteke
5/5/2008 7:14:06 PM

Ahh.. a large penny has just dropped... thanks to both of you, both solutions work.

 

0
dvans
5/5/2008 8:17:32 PM

why r u binding the data.. just use visible="true/false" .

even if u use the binding i think that expression does't meet the req

0
krishnav
5/6/2008 4:14:19 AM

The expression there was just an example to simplify. I'm actually using:

Users.IsInRole("Admin")
 
0
dvans
5/6/2008 8:39:42 AM
Reply:

Similar Artilces:

getting start with vb.net and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

How to get attribute set by script in web page?
Hello, everyone, I met a problem :( I can not find an api of Embedded Mozilla Browser in eclipse plug-in development. Here is the problem: 1. background, a example: A node in web page maybe like: <li id="abc" ...>...</li> And body node maybe like: <body init="initOnClick" ..>...</body> initOnclick may be: function initOnClick() { document.getElementById('abc').onclick = function(){...} } After page loaded, this function will be called. When I get DOM tree of this web page after it loaded in Embeded Mozilla Browser, I can get th...

Help getting started with a dynamic web form
I'm new to .NET so I was hoping someone could point me in the right direction. I have a form that needs to be dynamically created based on the contents of a XML file. The XML contains data for each 'row' to be created and what type of fields (textbox, custom select box, etc) should be displayed. The number of each type of field will vary from time to time. Using ASP I would have either used XSL to create a form or DOM to walk through the contents of the XML and display/name the proper fields. Using .NET I'm not sure what the proper method is to accomplish my goal. I can use XML c...

loop through controls to set attribute- was working.. now with new button on form... the attributes are not being set
I am only opening a new thread, because the old thread is old and I am not getting a response. Please see old thread... http://forums.asp.net/t/1113116.aspx Basically, I am setting a javacript on each textbox, to keep them from posting the form when you click the enter key. The solution worked, however, since then I added dropdown and button before all the textboxes, in the form, and this button's job is to grab the data of previously posted forms and repopulate all the text fields on this massive form. Well, ever since I added this dropdown and new button, the loop to add the javascr...

trying to set attributes of a web form element dynamically
I am sure this has already been covered, but I can't seem to find it: What I am trying to do is pull info from an outside source to dynamically build form control, and attributes settings. For example: dim controlString as string dim tempColor as string dim tempAttribute as string dim tempName as string tempColor = "'#FF00FF'" tempAttribute = "BackColor" tempName = "Label1" controlString = tempName & "." & tempAttribute & " = " & tempColor So the controlString would = "Label1.BackColor = '...

getting forms authentication settings from web.config file
I'm trying to programmatically determine the loginUrl defined in my web.config file. When debugging, I can see that: ConfigurationSettings.GetConfig("system.web/authentication") returns an object of type: System.Web.Configuration.AuthenticationConfig However, this class is inaccessible. Anyone know of any other way to get the authentication mode?? You could try using reflection. Alternatively (and probably better), you can load your web.config file into an XmlDocument and get the relevant attribute using an XPath expression. Something like this sho...

Help! loop through controls to set attribute- was working..Help! now with new button on form... the attributes are not being set
Hello.. I really need some help on this! I am only opening a new thread, because the old thread is old and I am not getting a response. Please see old thread... http://forums.asp.net/t/1113116.aspx Basically, I am setting a javacript on each textbox, to keep them from posting the form when you click the enter key. The solution worked, however, since then I added dropdown and button before all the textboxes, in the form, and this button's job is to grab the data of previously posted forms and repopulate all the text fields on this massive form. Well, ever since I added this dropdown...

How to start coding vb.net(web form and Crystal repotrs)
I use Crystal Report in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (please help me step by step,I try it before but not success) please help me !!! There is sample code and tutorials on my blog entry: http://dotnetjunkies.com/WebLog/richard.dudley/archive/2004/05/03/12692.aspxIf my post is your answer, please mar...

VB .net Web Form will not get contents of Text Box
I have created a web form with text boxes that are bound to a DataSet/DataView.  I have created button to navigate up and down the recordset.  That all works fine. I need to have the ability to edit/add text in any of the boxes and then when clicking "Save" button, it would build an UPDATE query to send to the database. When the Save button is clicked, I have coded to DIM a string var (strSQL) to use to build the SQL command.  For some reason, it will only get the text from a text box if the data was pulled the database.  If I add/edit data, then the SQL command will ha...

IN VS.Net how can i get a web form to scroll (design mode)
In design mode in VS.Net, there is a scroll bar next to the web form, but it is grayed out.  I can not figure out how to enable it.  I want to design a web form that is larger in size than the surface area shown in teh deisgn window.  Can someone help out with this?Thank you. VS design surface shows how the page is going to be rendered in the browser. Therefore, there is no 'virtual' large size. In the browser scroll bar appears if the browser window is smaller than the page content. You can make scroll bar to appear by enclosing page content in a large container e...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

getting values from a web form to windows form
Hot Requirement ..... Is there any possible of getting values from a web form to windows form ????? Yes One way i to use the WebRequest and WebResponse classes of the System.Net namespace. For example:  WebRequest request = WebRequest.Create("URL of the web page); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadLine(); ....    Reza Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way fut...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

Web resources about - Setting Visible attribute in a web form - asp.net.getting-started

Attribute - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Template:Attributes of God - Wikipedia, the free encyclopedia
Language: English Română Home Random Template:Attributes of God Part of a series on the Attributes of God Aseity Eternity Graciousness Holiness ...

Six Attributes Of The Perfect Facebook Page Administrator
So, here’s the thing: In many ways, hiring a Facebook page administrator is akin to hiring a poster child for your brand. This trusted manager ...

PANDA: Pose Aligned Networks for Deep Attribute Modeling - Facebook
We propose a method for inferring human attributes (such as gender, hair style, clothes style, expression, action) from images of people under ...

Facebook announces data partnerships to help advertisers target users by offline purchases and attributes ...
... will anonymously match data from consumer loyalty programs with user profiles in order to target ads by offline purchase habits and other attributes. ...

New Study Attributes Rapid Ageing Mainly To Environment Factors
New study explains why some people age faster than others.

Should I use the nofollow attribute on internal links? - YouTube
Regarding "nofollow" on internal links: Does it hurt? Does it help? I read different comments from Matt on this matter over time. What's the ...

Justin Trudeau attributes abortion stance to father's example
Liberal Leader Justin Trudeau says he is following an example set by his famous father when it comes to his position on election candidates and ...

Obama attributes western U.S. wildfires to climate change
... that has burned nearly 400 square miles in the north-central part of Washington state, along with blazes in other Western areas, can be attributed ...

Fifty Shades Of Grey Baby Births: Windsor Hospital Sees Spike In Births, Attribute Book
A significant spike in baby births at a hospital in Windsor, Ontario, has been attributed to the book Fifty Shades of Grey, which has become ...

Resources last updated: 1/16/2016 8:54:00 AM