Solved

Conditional statement in .aspx page

Posted on 2008-10-31
2
708 Views
Last Modified: 2010-04-21
I have a page where I am pulling data from a table and want to show contact information for everyone that is pulled. However, not everyone has all the information that I am going to show.  In my code behind I have a dataset, setup public variables and then use them in my page. How can I make it so in the example below the word Email: ...... only shows if there is email information? Basically I need an If Else statement in my main page. Here is how I am getting the values from the table:

commEmail = dsvss.Tables(0).Rows(0).Item("email")



h2>Committee Officers</h2>

		       <h3><%=commtitle%></h3>

                <p class="ofc"><b><%=commFullName%></b><br />

                <%=commCompany%><br />

                <%=commAddress1%><br />

                <%=commAddress2%><br />

                <%=commCity%>,&nbsp;<%=commState%>&nbsp;&nbsp;<%=commZip%><br>

                Phone:&nbsp;&nbsp;<%=commPhone%><br />

                FAX:&nbsp;&nbsp;<%=commFax%><br />

                Email:&nbsp;&nbsp;<a href="mailto:<%=commEmail%>"><%=commEmail%></a><br />

                Website:&nbsp;&nbsp;<a href="http://<%=commWebsite%>" target="_blank"><%=commWebsite%></a><br />

                Term:&nbsp;&nbsp;<%=commTerm%></p>

Open in new window

0
Comment
Question by:flukester
2 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 500 total points
ID: 22855321
Like this!
I made the example shorter to make it simpler because I did test it, but it is your code other than that.
      <h3><%=commtitle%></h3>

                <b><%=commFullName%></b><br />

                <%=commCompany%><br />

                <%=commAddress1%><br />
 

<% If Not commEmail Is Nothing And Not commEmail = String.Empty Then

%>

Email:&nbsp;&nbsp;<a href="mailto:<%=commEmail%>"><%=commEmail%></a><br />
 

<%End If %>

Open in new window

0
 

Author Closing Comment

by:flukester
ID: 31512211
Thanks ororiole
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now