Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2005, 06:18 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Very easy problem for an expert

I have managed to get round inserts, updates and deletes in C#. Now I have a page that retreives things from a database. What I want to do is something like this

if (variable is one value)

{

  display bit of html here

}

else

{

display bit of html here

}

I can do this in functions and it is very simple. however I want to do this in the html part of the page. I can't use braces, surely?


 
Old April 6th, 2005, 06:35 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could this be something I could use labels for?

 
Old April 10th, 2005, 12:44 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Not really a version 2 question but...
Define an asp:label control, with an id of lblData for example. In your code block:
Code:
if (myVar == "something")
{
  lblData.Text = "Some text here";
}
else
{
  lblData.Text = "Some different text here";
}
If you have many options use a switch statement instead of an if/else.

--

Joe (Microsoft MVP - XML)
 
Old April 21st, 2005, 07:18 AM
Friend of Wrox
 
Join Date: Apr 2005
Location: Cochin, , India.
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Conditional coding could be done in HTML part using ?: operator
inside the databinding blocks





Similar Threads
Thread Thread Starter Forum Replies Last Post
The expert programmers take a look ojbrowser Visual Studio 2005 0 August 12th, 2008 07:04 AM
easy pasting problem reverand Excel VBA 17 November 25th, 2005 01:11 AM
Sql Query Expert! itHighway Classic ASP Basics 1 June 5th, 2005 11:00 PM
Anyone Expert in SQL Queries? itHighway HTML Code Clinic 3 June 3rd, 2005 09:57 AM
is there any expert who can help me surya221 Classic ASP Databases 1 March 24th, 2005 10:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.