Connecting Tech Pros Worldwide Help | Site Map

Need an Expert Oppinion..

Member
 
Join Date: Mar 2007
Posts: 40
#1: Apr 9 '07
I have troubles with a technique I used to take my images from specific folder to show them by using ImageButton webcontrol
It is still working properly offline, but when I uploaded my website, it didn't work, everything is going well and there is no errors, it's loading the ImageButtons with names but it doesn't show the image itself, what could be the possibilities..

If you require, I would send you the code, but please I need a prompt reply, it's urgent
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#2: Apr 9 '07

re: Need an Expert Oppinion..


Quote:

Originally Posted by Eyadtrabulsi

I have troubles with a technique I used to take my images from specific folder to show them by using ImageButton webcontrol
It is still working properly offline, but when I uploaded my website, it didn't work, everything is going well and there is no errors, it's loading the ImageButtons with names but it doesn't show the image itself, what could be the possibilities..

If you require, I would send you the code, but please I need a prompt reply, it's urgent

Is the image location correct? Take a look at the generated HTML and see if it points to the correct location. Then check to make sure the image is there.
Needs Regular Fix
 
Join Date: Mar 2007
Posts: 304
#3: Apr 9 '07

re: Need an Expert Oppinion..


Quote:

Originally Posted by Eyadtrabulsi

I have troubles with a technique I used to take my images from specific folder to show them by using ImageButton webcontrol
It is still working properly offline, but when I uploaded my website, it didn't work, everything is going well and there is no errors, it's loading the ImageButtons with names but it doesn't show the image itself, what could be the possibilities..

If you require, I would send you the code, but please I need a prompt reply, it's urgent

posting your code will be helpful in determining the error.
Member
 
Join Date: Mar 2007
Posts: 40
#4: Apr 11 '07

re: Need an Expert Oppinion..


Quote:

Originally Posted by gomzi

posting your code will be helpful in determining the error.

You could make sure that the location of the images is correct because when you hoover over the images' button it gives you the name of the image which is taken by "code genereation of" the image itself

here is the code:

public void Page_Load(object sender, EventArgs e)
{

int i = 0;

// get the address of the directory, then seach for files with .JPG extension inside
string add = Server.MapPath("pics\\gallery\\");
string[] images = Directory.GetFiles(add , "*.jpg");

// Create ImageButton Array, and use it to store & present result images in determine specifications
ImageButton[] imageBtt = new ImageButton[images.Length];
foreach (string image in images)
{
// Add special character \\ to the address to add it to .ImageURL - e.g. \" adds "

imageBtt[i] = new ImageButton();
imageBtt[i].Width = 70;
imageBtt[i].Height = 47;
imageBtt[i].ID = Path.GetFileNameWithoutExtension(image);
imageBtt[i].Visible = true;
imageBtt[i].ToolTip = Path.GetFileNameWithoutExtension(image);
imageBtt[i].ImageUrl = "\\\\" + image;
imageBtt[i].Click += new System.Web.UI.ImageClickEventHandler(ImageButton_C lick);

ContentPlaceHolder3.Controls.Add(imageBtt[i]);
i++;
}


and you could browse through the website to test the results:
http://www.qebab.com/Galleries.aspx
Needs Regular Fix
 
Join Date: Jul 2006
Location: India,Hyderabad
Posts: 367
#5: Apr 11 '07

re: Need an Expert Oppinion..


Hello

you said its working fine in offline you mean its working in your system where actually you developed that website ,if so is the case first see the path of the images you are using ,they may be refered to your local drive path,replace that path by ..//image.img(your image) nothing but the default path for your image
try with this ,it maywork fine

Good Luck
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#6: Apr 11 '07

re: Need an Expert Oppinion..


Eyadtrabulsi, take a look at the generated HTML and see if the image path is correct.
Member
 
Join Date: Mar 2007
Posts: 40
#7: Apr 11 '07

re: Need an Expert Oppinion..


When I save it in .htm file, I checked the SRC of the image it looks empty as below:

type=image src="" name=ctl00$ContentPlaceHolder3$bath-m><INPUT
id=ctl00_ContentPlaceHolder3_bath-m1 title=bath-m1
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 70px; HEIGHT: 47px; BORDER-RIGHT-WIDTH: 0px"

but what I'm thinking of that as it's showing in the C# code above, I made it like automatically it searchs for the images in specific directory which is "gallery" here then it takes all the informations from the image's file itself, and as you noticed "for instance" the tooltip reflects the name of the image so I don't think there is something wrong with the path, because it would not give me the right information if it didn't reach the image's file
Could it be by the format Server.MapPath returns to ImageURL, but why did it work offline??!!
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#8: Apr 11 '07

re: Need an Expert Oppinion..


I am not sure why it worked offline...try taking a look at the source for the offline version. Compare the two; see if you can find a difference. Regardless, this is the source of your problem.

Perhaps you should go back the the C# code and see if it is using the correct paths for gathering your gallery. What may be happening is that the production paths are different than the development paths, therefor debugging it on the server will work, but rolling the code out breaks it.
Member
 
Join Date: Mar 2007
Posts: 40
#9: Apr 12 '07

re: Need an Expert Oppinion..


I saved the .htm file by the offline version and checked out the code, it's the same but with SRC:

type=image src="Qebab Gallery_files/bath-m.jpg"
name=ctl00$ContentPlaceHolder3$bath-m><INPUT
id=ctl00_ContentPlaceHolder3_bath-m1 title=bath-m1
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 70px; HEIGHT: 47px; BORDER-RIGHT-WIDTH: 0px"

but when you notice that all the other information are the same, and with using Server.MapPath("pics\\gallery\\");
with both.. which discover the path on the server it works on, beside that when you click on any of the images "online or offline" you see the reflected path on the new generated page's URL "which I send to get the same URL for the image to have it in bigger size when clicking" and which is correct URL
With everything I mentioned I feel that the error is in showing the image not in the image's path, What do you think??
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#10: Apr 12 '07

re: Need an Expert Oppinion..


The offline version has the SRC piece filled, and the online version does not. This is the source of your problem.
Member
 
Join Date: Mar 2007
Posts: 40
#11: Apr 12 '07

re: Need an Expert Oppinion..


Is there anyway to solve it..?? or is there any logical reason ??

I realy need an expert's oppinion...
Motoma's Avatar
Moderator
 
Join Date: Jan 2007
Location: Maine, USA
Posts: 2,904
#12: Apr 12 '07

re: Need an Expert Oppinion..


Quote:

Originally Posted by Eyadtrabulsi

Is there anyway to solve it..?? or is there any logical reason ??

I realy need an expert's oppinion...

Is there a pics\\gallery\\ folder in your web server's directory.
I can't help you out anymore than this. You are the only one who knows what your file structure looks like, and what your code looks like.
Nikky's Avatar
Newbie
 
Join Date: Nov 2006
Posts: 25
#13: Apr 13 '07

re: Need an Expert Oppinion..


1.save ur form and the image in the same directory. and check its path in html coading.

2.Or try ImageUrl="~/myImage.jpg"
It will directly take dynamic path
Member
 
Join Date: Mar 2007
Posts: 40
#14: Apr 14 '07

re: Need an Expert Oppinion..


Of corse I have \\pics\\gallery directory and I have all my images inside
The root directory is called qebab I have all my directories inside so you could find pics and then gallery inside..

As for using ~/myimage.jpg I can not because my code detects the files itself inside "gallery" then it represents them, so I don't already know the file's name

I tried to use the virtual path as follows
string path = "~/pics/gallery/";
but it gave me this error

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'c:\windows\system32\inetsrv\~\pics\gallery'
Member
 
Join Date: Mar 2007
Posts: 40
#15: Apr 14 '07

re: Need an Expert Oppinion..


Now I fixed it up

I kept Server.MapPath"\\pics\\gallery\\" like it is, but i changed the ImageURL as follows:

imageBtt[i].ImageUrl = "~/pics/gallery/" + Path.GetFileNameWithoutExtension(image) + ".jpg";

Elhamdullah it's going well now

Thank you all for trying to help me ;-)
Reply


Similar .NET Framework bytes