Webica Web Page
Copyright protected.© 1999-2008 Webica Ltd. All rights reserved.
Webica Ltd is a privately owned independent U.K Company No. 3832693 .
Website signifies your agreement to the Terms of Use. Acknowledgement Microsoft™ is the trademark of Microsoft Corporation Inc.
 
 
2.0
 
BROWSE E-CHAPTERS
Back to top
back to top
By image I am referring to a graphic file such as jpeg, png or gif image file. This was one of the problems I had to solve for this site. I wanted a consistent simple look for each page. Its helpful to say each page is article and each article is record in the database. Some records will have an image, some won’t. So rather than having an empty image tag appearing on the page for those records that don’t have an image I needed the system to try and display an image if there is one to display.
Rather than dragging and dropping an image control from the Visual Studio.NET toolbox the answer is to only create the control that displays the image if there is an image to display i.e. conditionally. This can be achieved by programmatically declaring an image control in the pages code-behind file.

C# developers can use this shortcut, add
using visual = System.Web.UI.WebControls.Image;

This is known as using an alias, you can do it with any assembly your code references, its not needed here but it does make coding easier.






There are several ways to achieve most programatic tasks like this. One way is to say that every page should be able to change its behaviour at runtime, meaning it should have a property which can be set by the record it is reading from the database, more specifically which is set by the particular field in a the record which 'says' I have a picture and i want it displayed.
Typically your code needs to read the field values in each record to determine what it displays, if one of those value is a boolean with 1 meaning there is an image or 0 meaning there is not a image then a simple conditional test can be used. The code that does this conditional test could then call then addpic() method ( in the code view above).
&
Content Management Controls Conditionally displaying an image
 
Code
Listing All Titles for Content Management Controls
To view please select a title from the list below
Fourth Generation Content Management Systems and Information Processing
online editors via wizards
Enhanced office document ActionPanes
Accessibility Web Page Testing for Developers
Two new content engines launched for the Web, built with .Net
Relanzamiento europeo de Webica para .NET.
Experimenting with Google and Multi-lingual Advertising
Positioning Advertisements (ads) Programmatically with ASP.NET
Switching Advertisements (ads) ON and OFF Programmatically with ASP.NET
How to create a database driven Google sitemap
Improve your site Ranking - link to webica.net
Do you need Keywords to be found - GET YOUR MESSAGE OUT THERE
Can you make every word count with the ultimate CMS
hairy ball tampering BBC1 new years eve
hairy ball tampering BBC1 new years eve
hairy ball tampering
Custom Server Controls for CMS2002
Custom Server Controls
CS2002 server extensions
CS2002 server extensions
Microsoft Content Management Server 2002
Using recommended Keywords to be found
What is Content Control
Conditionally displaying an image
Content Management System

Portals vs Content Management Systems
Contact
Google
WWW WEBICA.NET
Search all Google Indexed pages on Webica.net
ASP.NET C# quiz engine planned
International Headline News
For those who know that .NET and the WEB can be beyound your reach, but that they remain within your grasp.