Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2009, 01:02 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile profile

Hello friends,
While working with WebShop I came across profile. As using profile it shows the particular users' record. From that point I want to insert image of user. For this I have given a fileupload control to user and they can upload their photo(if they wish).
Now to display image of logged in user shoul be displayed on every page (like orkut), for this I am using Repeater control on master page. But I am having problem in getting the image and also don't know what should I put in the ItemTemplate of Repeater so that it gets bound with the repeater.
Currently I am using the following code

Code:
<ItemTemplate >
        <asp:Image ID ="Imageurl" runat ="server" ImageUrl='<%# Eval ("PropertyNames") %>' />
</ItemTemplate>
And in the code behind file

Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Profile.ProfileCompleted = True Then
            If Profile.Photo IsNot Nothing Then
                Repeater1.Visible = True
                Repeater1.DataSource = Profile.Photo
                Repeater1.DataBind()
            End If
        End If
    End Sub
Any suggestion in the direction is appreciated.
Thank you...
 
Old November 29th, 2009, 04:09 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

Maybe someone with more experience will swing by, but here's what I can make out.

A repeater control is used when you have multiple items to display in a certain template. A repeater would only need to be used here if you have multiple images. If you only have one image, get rid of the repeater and keep only the asp:Image tag.
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old November 29th, 2009, 04:17 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Thanks for replying. But yet one question to ask.
How I will assign a particular image of particular user i.e. who is currently logged in (like orkut) to the asp:image tag.
Any suggestion further are really appreciated.
Thank you once again.
 
Old November 29th, 2009, 06:09 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Provided that Profile.Photo contains a virtual path to an image, why not simply assign the ImageUrl of the image?

Imageurl.ImageUrl = Profile.Photo

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
sophia (November 29th, 2009)
 
Old November 29th, 2009, 11:21 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Once again sir, you really helped me out.
I initially was using Repeater control to show the image of logged in user and inside the ItemTemplate I used the asp:image tag. But now I removed the repeater and worked with only asp:image tag. And it is really working.
Thank you once again.
 
Old November 29th, 2009, 12:37 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile Image to anonymous users.

Hello Sir,
Well Showing Image of logged in user is working fine. I am trying to show the Default Image to anonymous users. For this I am using the following code

Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Profile.Photo IsNot Nothing Then
            Imageurl.ImageUrl = Profile.Photo
        Else
            Imageurl.ImageUrl = "~/Image/Default.jpg"
        End If
End Sub
But it is not working, it shows the Red Cross to the anonymous users instead of Default photo. Is there any thing wrong with the code or am I missing something?
 
Old November 29th, 2009, 12:50 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The most obvious question is: do you have a file called Default.jpg in the Image (singular?) folder?

The second question is: what does Fiddler (www.fiddlertool.com) tell you?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old November 29th, 2009, 01:14 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Yes sir I do have Default.jpg file in the specified directory.
And sorry, I didn't get by fiddler.
I have also tried the LoginView but when putting the asp:image control in LoggedInTemplate then I can not access the ImageUrl.ImageUrl
And please sir specify the fiddler here as I find your teaching method most convenient.
Thank you.
 
Old November 29th, 2009, 05:39 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
I find your teaching method most convenient.
That feeling is not entirely mutual. I am not here to teach you things. Teaching is done by books, web sites, trainings, and teachers, not just by a forum.

In other words: you need to figure stuff out on your own as well. If you don't know what Fiddler is, follow the link I posted. Watch the introduction video, Google 20 pages talking about Fiddler and experiment a bit. Then you understand what it's used for and how you can use it to see the difference between a 404 and a 403 which may aid you in understanding why the image doesn't show up.

Likewise with the LoginView control. Do you ever Google for problems like this? It doesn't look like it, or you're asking strange questions. Searching for "access control in LoginView" - the exact keywords of your question here - should bring up the answer to your question in a few seconds.

Learn to use these tools and you'll become a better developer who doesn't need to rely on a teacher who doesn't believe in Forum teaching..... ;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old November 30th, 2009, 10:51 AM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Quote:
Do you ever Google for problems like this? It doesn't look like it, or you're asking strange questions.

Learn to use these tools and you'll become a better developer who doesn't need to rely on a teacher who doesn't believe in Forum teaching..... ;-)
well sir I do google for the problem before I bother you. I did google the topic but the solution was giving an error regarding object instance.
And yeah thank you for sharing fiddler and encouraging me that I can also be a better developer
Thank you for this.
And now the problem is solved. I did use the IsAnonymous property of the Profile.
Thank you once again.

Keep smiling





Similar Threads
Thread Thread Starter Forum Replies Last Post
Profile common bendjoe BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 13 October 12th, 2010 02:26 AM
Profile danievermaak BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 3 July 5th, 2010 09:26 PM
Profile Management aspnet35 General .NET 0 October 29th, 2007 04:53 AM
delete profile ?? n/a Forum and Wrox.com Feedback 6 August 8th, 2003 03:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.