!!!!! Image on master page wont show when image url is set to a image from content page !!!!!!

 Hi guys,

 I have this problem which i cannot seem to understand...

 here goes...

 i have a master page and an image control on it....it is a social networking website and then i have a content page..there is a link button on the master page when when clicked shows a modal popup which has a fileupload control and a user can submit an image file...when he does so the image get saved in a directory and also its complete address is saved in the database...

now 2 problems...

 

after committing these actions (on the master page code file ) i set the image url to the saved path (in a temporary string, which gets tored in the database) but the image doesnt show...it has been saved in the directory so why????

and the second one...say we forget this first problem...the image is in the directory and the path is in the database....so on page load of content page i find the master page Image control and set its image url to the value form DB but it still doesnt show...

why this happens i have no idea....plz guys if i am missing something please let me know...

code on master page......vb file

 snippet for server click event of ok button on MODAL POPUP

Try
                con.Open()
                trans = con.BeginTransaction(IsolationLevel.ReadCommitted)
                Dim s As String = "update general set upimg_1='" & finalPath & "' where user_id='" & userID & "'"
                MsgBox(s)
                cmd = New OleDbCommand(s, con, trans)
                'attempt to save the file
newBMP.Save(finalPath)
cmd.ExecuteNonQuery()
trans.Commit()
Image1.ImageUrl = finalPath
Catch ex As Exception
MsgBox("
An error has occured,please try again later" & ex.Message)
trans.Rollback()
Finally con.Close()
 
and for the content page...
 
Sub setProfilePic()
cmd = New OleDbCommand("select upimg_1 from general where user_id='" & Session("user_id") & "'", con) Dim reader As OleDbDataReader con.Open() reader = cmd.ExecuteReader() reader.Read() If reader.HasRows Then Dim img As Image img = CType(Master.FindControl("Image1"), Image)
img.ImageUrl = reader("
upimg_1").ToString()
End If con.Close()
  in debugging mode i have searched and it finds this image control and its imageurl is set the value from db but it still doesnt show...
plz help guys....what am i doing wrong here 
 
 
  

 


0
pankajsingh5k
3/6/2009 12:52:35 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

5 Replies
1407 Views

Similar Articles

[PageSpeed] 57

I've made a small test now with a image control on the master page and a function in the content page that set's the image url and it works fine.

Maybe try hardcoding a value instead of setting it to your reader's value, just to test.

If it works then it might not be resolving the value of your reader correctly.

PS: Make sure the image is actually there and relative to your page calling it.

Jean


Programming - You're doing it all wrong..
0
JeanT
3/6/2009 1:20:12 PM

i did the same test and it worked as well and thanx to that i have found the real problem...

i was resizing the image before saving it using Image and graphics classes and then save it....noew these images can be viewed in MS PAINT and Windows Picture and Fax Viewer but the Image control cannot display them

when set to other pictures in the directory it works well.....

tried the image button but it cannot show it as well.....so i think i will change my code to resize the images

i will post this code in an appropriate thread..


0
pankajsingh5k
3/7/2009 7:31:23 AM

 i dont know if any of you have encountered this but

 in my above posted code if i manually set the path as 

 

Dim img As Image
            img = CType(Master.FindControl("Image1"), Image)
            img.ImageUrl = "D:\websites\sandesh4u\userImages\community\1_PANKAJ.jpg"
then it shows the image
but when set to
 
cmd = New OleDbCommand("select upimg_1 from general where user_id='" & Session("user_id") & "'", con)
        Dim reader As OleDbDataReader
        con.Open()
        reader = cmd.ExecuteReader()
        reader.Read()
        If reader.HasRows Then
            Dim img As Image
            img = CType(Master.FindControl("Image1"), Image)
'img.ImageUrl = "D:\websites\sandesh4u\userImages\community\1_PANKAJ.jpg" Dim s As String s = reader("
upimg_1").ToString()
img.ImageUrl = s
End If con.Close()
  it doesnt work...now what is the problem??? has anyone faced this issue??
Confused
Crying 
  
0
pankajsingh5k
3/7/2009 8:56:27 AM

i figured it out...

i was really being stupid because i wasnt using trim() when storeing it in the database and recieving it

sorry for all the trouble...

Embarrassed

moral of the story : ALWAYS USE TRIM WHEN HANDLING STRING STORAGE IN DATABASE

0
pankajsingh5k
3/7/2009 9:13:58 AM

Hmm

Glad you got it... I thought you might also maybe want to use "ResolveUrl" on your reader value.

 


Programming - You're doing it all wrong..
0
JeanT
3/9/2009 6:15:14 AM
Reply:

Similar Artilces:

How to put an image that references a image control in a master page
Hello everyone,Currently I have a master page with a report logo, depending on which report needs to be executed, I want the image on the master page to change. I am thinking of trying to do this within the resource file of the report, does anyone know how this can be done?  Thank you.  In your master page define a function which will set the image url for the report logo image  e.g:Public Sub SetLogoImageUrl(ByVal imageUrl As String) imgMyReportLogo.ImageUrl = imageUrl End Sub  In your webfrom add this line <%@ MasterType VirtualPath="~/Reports/myre...

How to prevent Master page images and content page flicker while navigate the menu bar.
Hi, I am suffering a lot for while navigating my application it seems awkward, because I used master and content page techniques. In my master page I drived stuff called Header,footer and side menu bar(UltraWebListBar).On the header we placed some asp.net buttons and its has designed through CSS. All the functionality is working fine except page and images flickering. Its very urgent to fix this issue. Please help me as soon as possible. I have seen some article in forum.asp.net, more guys suggested to reslove this problem using Atlas ASP.net. I am new in Atlas, please give me a right direct...

image in my footer.ascx control wont show up in my master page??
I have a footer.ascx control that I designed. It shows all my info even the image on the actual control page itself but when I use the control on any .aspx page my image doesn't show up only my text. Can someone help me on how to use an image in a control so that it shows up on my pages??  Control page code: <%@ Control Language="VB" AutoEventWireup="false" CodeFile="footer.ascx.vb" Inherits="footer" %> <p align="center" class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center">...

image not showing up in image control, I have to refresh page to make it appear?
 Hi,I have an image control that Im loading with a picture that the user uploads, but the problem is that I have to refresh the page in order to show the new pic, otherwise the old pic stays there. my code:                    //save to disk                    path = "C:/Inetpub/wwwroot/appName/images/Headshots/" + this.User.Identity.Name + ".jpg";     ...

image not showing in image on web page
I have a dropdown list of 100+ images that reside on a server i put the full \\servedr\dir\dirsub\nam.gif in the imagerurl. but the image is now showing the images are not on my web server but a file server why wont they show. Hello my friend, The files need to be url locations like www.mysite.com/myimage.gif   Kind regards Scotty   I found my problem ( i have fat fingers) i forgot the the 2 '\\' in front of my path...

How to show page background image in master page
 am using a master page for my asp.net website.I am using a backgroundimage in the master page and all the pages should have the background image.When I put the BG image on the master page, it works fine with the content pages that are in the same folder (root folder) as the master page. But, the pages in subfolders does not show the background image. I even tried using the full path also like "~/Images/MyBGimage.gif". But it didnt work.This happened with other images also. But when I changed it to runat server it worked fine. But I could not get it corrected for the backgroun...

relative file path to image URL/background images/other pages in the site NOT recognized consitently over pages
Hi, in my web site I encoutered an overall problem with stating the right relative path to images and/or URLs they are incosistent - path to an image in the master page file like (or in the related CSS file): background-image:url(Website/images/side_frame.jpg); it will not load on all pages - why's that?the same with relative URL paths su as: <a href="Content/Help/Get-started.aspx"> I used different prefix combination such as: ~/ or ../../  but the it solve the problem on one type of page and create another Any advice?   ThanksEran   ~/ is fo...

is there any way I can get the image from the database and use the Image control to show it in the page.
HI, I have a question, if I stored images into the SQL SERVER TABLE. is there any way I can get the image from the database and use the Image control to show it in the page. thanks Yes you can store them in a database, but they do take up a good chunk of room.  You might want to consider hosting them in a folder on your site and have the database field point to the url.  Remember to mark any post that is helpful as an answer and change posts status to Resolved to help others in the future. cheers,BChttp://voidimpossible.com Hi, here is the good resource http://www.odetocod...

Master Pages, Content Pages, Images, Javascript Rollovers
Hello everyone, Have a question about getting javascript rollovers working in various content pages. Here is the directory layout. MasterPage/UsingBytes.MasterImages/etc..Content/Default.aspxContent/Account/Login.aspx So in the master page i have defined a asp:ImageButton which will show up on every page in any directory just fine becuase i am declaring it with runat="server" and using the ImageUrl path as ~/Images/etc... But the problem i have arises when i add javascript onmouseover and onmouseout to this button, (as i would also like the javascript rollovers to be shown in everypage ...

set image url programmatically for image control
I have a print page that uses an image control to display an image that is saved in a directory that is dynamically created upon a session start. I have the path readily available for the image control....but I am failing to get the image to display in the image control.... what is the syntax to properly set the url for an image control programmatically in the code behind?   the control is named printImage   thanks in advance   Eric printImage.src= printImage.ImageUrl = "your URL";simple as that. ]|[ I am not getting the .src in intellisense for the...

change image in image control on page refresh
 Hi       I am with C# asp.net,  in my web form I have a image control and in a folder named images I have 10 images. How can I change image controls image on page refresh randomly selecting images from the images folderThanks in advance Regards Anu Palavila You can either use asp.net Adrotator control.. or you can simply write a piece of code to randomly pick one image form the image array...This code will show images from Images folder randomly on every page refresh.. private void showRandomImage()    {   &nb...

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

Web resources about - !!!!! Image on master page wont show when image url is set to a image from content page !!!!!! - asp.net.navigation-controls

Help:Contents - Wikipedia, the free encyclopedia
Templates are special pages that contain boilerplate text intended to be displayed on more than one page in Wikipedia. This Tip of the day box ...

Portal:Contents/Culture and the arts - Wikipedia, the free encyclopedia
The word culture is derived from the Latin root cultura or cultus meaning to "inhabit, cultivate, or honour". In general, culture refers to human ...

Netflix: Website that unlocks US content claims content being blocked
A website that unlocks US streaming movies and TV shows says Netflix has begun blocking Australian access to that content.

Nielsen Adds Facebook TV Conversation Data to Renamed Social Content Ratings
... giant Nielsen is adding conversation data from Facebook to its Nielsen Twitter TV Ratings , rechristening it as Nielsen Social Content Ratings. ...

5 ways Cupertino could improve content search on Apple TV
... a great movie or TV show is far easier than on other media streaming devices such as Amazon Fire TV and Roku. Still, searching for content ...

Verizon Wireless selling data cap exemptions to content providers
(credit: Verizon Wireless ) Verizon Wireless, like AT&T before it, is now charging online content providers a fee to get their services exempted ...

Horizon Award Winners Highlight Female Helmers; SpectreVision & Ubisoft Team For VR Content – Sundance ...
Four winners of the second annual Horizon Award were announced today ahead of the kickoff of the Sundance Film Festival . The award seeks to ...

Undertale adds mysterious new content in latest update
Undertale has received an update which adds new content and dialogue, even though the patch was said to only "fix bugs and increase compatibility." ...

Brave Browser App Looks to Block Intrusive Ads, Replaces With Clean Ads to Help Content Creators
... greatly hindered. When you first load up a webpage, a site using ad technology that tracks you can place cookies and other miscellaneous content ...

How to Strike the Right Content Balance for Maximum Reach
How to Strike the Right Content Balance for Maximum Reach written by Guest Post read more at Duct Tape Marketing photo credit: Shutterstock ...

Resources last updated: 1/23/2016 9:07:54 PM