Solved

Hide hyperlink is asp.net page if navigate URL is null

Posted on 2015-02-15
4
835 Views
Last Modified: 2015-02-16
I have several hyperlinks on a asp.net web form that are getting the navigate URL value by using databinding.   I have no problem with displaying the links with the URL.    If no problem with navigate url value is returned for a hyperlink but I no value is return I want to hind the link by setting the visible property to false.   I am not sure how to do it.

Here is how I am getting the navigate URL value:

 <asp:HyperLink ID="HyperLink1" Visible="true" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "article_url")%>' runat="server">Click here for more information</asp:HyperLink>
                                 
Any help would be appreciated.

Thanks
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 40611222
This is how I'd do it. First, I'd add an override for the SaveStateComplete event in my code behind.

Then, in this event, I'd check to see if the value for the NavigateUrl for that element is string.Emtpy or null. If it is, then set the element to Visible = false.
0
 
LVL 8

Expert Comment

by:Naitik Gamit
ID: 40611903
look at this link,conversation how to hide hyperlink if data is null

http://stackoverflow.com/questions/19059859/hide-hyperlink-if-data-is-null

hope this will help you to solve the problem.
0
 
LVL 15

Accepted Solution

by:
Lokesh B R earned 500 total points
ID: 40612036
Hi,

You hide like this.

 <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "article_url")%>' runat="server"
  Visible='<%# DataBinder.Eval(Container.DataItem, "article_url")!= null ? true : false  %>'>Click here for more information</asp:HyperLink>

Open in new window

0
 

Author Comment

by:Mike_Stevens
ID: 40612724
Lokesh.....your example causes syntax errors.  

it runs a 'syntax error' and Error 11      'null' is not declared. 'Null' constant is no longer supported; use 'System.DBNull' instead.
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question