473,327 Members | 2,025 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,327 software developers and data experts.

Image Not Showing

Hi

I am using Borland Developer 2006 (C# code behind) to create a 3
Column CSS app. 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 html 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 during the program run..

"<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

===============================================

<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 29 '07 #1
0 1327

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:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.