473,388 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Image Not Showing

Hi

I am using Borland Developer 2006, C# web application. Fairly new to
the .net platform and very new to repeaters.

I have 2 repeaters on a page, both of which are filled from a
database. The Links in the left hand column are created correctly and
displayed. The images/Links (hrefs) in the right hand column are the
problem. The links are displayed correctly but the images are not
displayed. The html is build dynamically. I have debugged the
application and copied the link that has been built. When I paste it
into the html and run it the images are displayed correctly. It is
driving me nuts.

The following is an example of the string that is built dynamically.

"<p><ASP:Image id="TheImage1" runat="server" height="80px"
width="140px" imageurl="Images/Image2.jpg" alternatetext = "Google Web
Page"></ASP:Image><br><a href="http://www.google.co.uk">Google</a></
p>"

In all cases the images exist.

Can anyone please help ?

Thanks in advance for any assistance offered.
Iain
3 Column CSS example.

<html>
<head>
<title>My Title</title>
<meta http-equiv="content-type" content="text/html;
charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="CSS/Standard.css" />
</head>
<body>

<div id="content">
<h1>My Title</h1>
<p>This is The Main Body Of The Page</p>

</div>
<!-- The following is the left hand column. It is built mainly
from a table of links from a database table -->
<div id="side1">
<h4>Search Our Pages</h4>
<form method="post" action="">
<input class="inputBox" name="textfield" class="inputBox" /><br />
<input type="submit" name="Submit" value="Submit" /><br /><br />
</form>
<!-- The first repeater -->
<p>
<asp:Repeater id="Repeater1" OnItemCreated="R1_ItemCreated"
runat="server">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem, "Ticker") %>
</ItemTemplate>
</asp:Repeater>
</p>

<!-- The right hand column. It is built mainly from a table of
Images/Links from a database table -->
<!-- This is where the problem lies. The links are displayed
but the images are not -->
</div>
<div id="side2" border="1">
<p>
<asp:Repeater id="Repeater2" OnItemCreated="R1_ItemCreated"
runat="server">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem, "Ticker") %>
</ItemTemplate>
</asp:Repeater>
</p>
</div>
</body>
</html>

The code behind is

protected void R1_ItemCreated(Object Sender, RepeaterItemEventArgs
e)
{
String iTypeText = "";

switch (e.Item.ItemType) {
case ListItemType.Item:
iTypeText = "Item";
break;
case ListItemType.AlternatingItem:
iTypeText = "AlternatingItem";
break;
case ListItemType.Header:
iTypeText = "Header";
break;
case ListItemType.Footer:
iTypeText = "Footer";
break;
case ListItemType.Separator:
iTypeText = "Separator";
break;
}
}

public class PositionData
{

private string ticker;

public PositionData(string name, string ticker, string PType,
string PImageId, string PTheImageName, string TheAlternateText, string
PTheImageText, string PHRef)
{
this.ticker = "";
if (PType == "Link")
{
this.ticker = "<li><a href=" + ticker.Trim() + ">" + name.Trim()
+ "</a></li>";
};
if (PType == "AdBox")
{
this.ticker = "<p><ASP:Image
id=\"" + PImageId + "\" runat=\"server\" height=\"80px\" width=\"140px
\" imageurl=\"" + PTheImageName + "\" alternatetext = \"" +
TheAlternateText + "\"></ASP:Image><br><a href=\"" + PHRef + "\">" +
PTheImageText + "</a></p>";
};
}

public string Ticker
{
get
{
return ticker;
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
string LLabel = "";
ArrayList values = new ArrayList();

OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
Server.MapPath("Databases/TestDB.mdb"));

OleDbCommand cmd = new OleDbCommand();

string LSqlString = "Select * From Links";
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = LSqlString;
OleDbDataReader reader = cmd.ExecuteReader();
LLabel = "<ul>";
values.Add(new PositionData(LLabel, "", "","", "", "", "", ""));
while (reader.Read())
{
string LFormName = reader[0].ToString();
string LSection = reader[1].ToString();
string LLinkName = reader[2].ToString();
string LLink = reader[3].ToString();
values.Add(new PositionData(LLinkName, LLink, "Link","", "", "",
"", ""));
}
LLabel = "</ul>";
values.Add(new PositionData(LLabel, "", "","", "", "", "", ""));
Repeater1.DataSource = values;
Repeater1.DataBind();

con.Close();

values.Clear();

LSqlString = "Select * From Images";
con.Open();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = LSqlString;
OleDbDataReader reader2 = cmd.ExecuteReader();

int LCounter = 1;
LLabel = "<div class=\"adbox\">";
values.Add(new PositionData(LLabel, "", "","", "", "", "", ""));

while (reader2.Read())
{
string ImageFormName = reader2[0].ToString();
string ImageSection = reader2[1].ToString();
string TheImageText = reader2[2].ToString();
string TheImageName = reader2[3].ToString();
string TheAlternatetext = reader2[4].ToString();
string TheHRef = reader2[5].ToString();
values.Add(new PositionData("", "", "AdBox", "TheImage" +
LCounter.ToString(), TheImageName, TheAlternatetext, TheImageText,
TheHRef));
}
Repeater2.DataSource = values;
Repeater2.DataBind();

LLabel = "<\\div>" ;
values.Add(new PositionData(LLabel, "", "","", "", "", "", ""));

con.Close();

}

May 28 '07 #1
0 1688

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: cjl | last post by:
OK: I am really scratching my head over a preload / image swapping problem, so I started conducting experiments: http://www.saintrays.net/experiment1.html...
7
by: karthikeyan | last post by:
Hi, I am having some problems hosting my website. Everything works fine in my local machine but when I upload to propduction server, my images won't load properly. I have my state configuration...
10
by: bessington | last post by:
hey all, i'm having a rather bizarre problem.. the image tag i have declared in my xhtml is not showing in safari / konqueror but showing just fine in Firefox, IE, Opera... this is a complete...
9
by: Rajesh | last post by:
Hi all, Im gonna display a list of images in an aspx page from sql server Db.Each image has a link.When someone clicks the image i want the width and size of the image to be displayed at the...
3
by: Mark Szlazak | last post by:
The following page simulates a pool cue and cue ball: http://members.aol.com/myscript/cue.html Mouse cursor position around the cue ball determines where a roll-over of 179 pool cue images is...
7
by: needin4mation | last post by:
Hi, I have an Access 2002 - 2003 database. I am using Access 2003. Whenever I link an image all it shows is the filename. Not the image. Other versions of Access can link the image just fine. ...
0
by: Svein Erik | last post by:
I'm developing an application in C#.NET 2005. The app is going to have an image with a specific size, let's say 800x600 px, this is a map of a go-cart lane. And on top of this image i'm going to...
8
by: Gabriella | last post by:
Hi, I have the CSS class below, and the image (pro.gif) is not showing on my page. It is showing ONLY where's some text in the div, but all I need is the image itself. ..pro {background-image:...
3
by: Sandeep Singh Sekhon | last post by:
I am developing an application in ASP.NET 1.1. on one page I allow the user to upload and delete the files to the server. When I delete the file, I physically delete the file from the location....
3
by: Switch4Mac | last post by:
Hi, I want to insert an ad in my MasterPage. So in the MasterPage, I have this piece of code: <asp:Image ID="GatesAd" runat="server"...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.