locked
show image of user after successful login in asp.net Entity Framework RRS feed

  • Question

  • User186310208 posted

    when user register he/she upload his/her image after that user image is display in profile form...

    here is my code.

    <asp:Image runat="server" ID="imgPhoto"
    ImageAlign="Top" Width="118" Height="118" />

    using (WallpaperEntities4 ctx = new WallpaperEntities4())
    {
    string UName = Convert.ToString(Session["UserName"]);
    var query = (from c in ctx.Users
    where c.UserName == UName
    select new
    {
    c.Image,
    c.Name,
    c.UserName,
    c.EmailID,


    }).FirstOrDefault();
    if (query != null)
    {
    imgPhoto.ImageUrl = query.Image;
    TxtName.Text = query.Name;
    lblUserName.Text = query.UserName;
    TxtEmailID.Text = query.EmailID;

    Wednesday, August 5, 2020 5:18 AM

Answers

  • User-1330468790 posted

    Hi Nirvriti Sharma,

     

    Have your problem solved?

    If you still have any problem, feel free to let me know.

     

    Best regards,

    Sean

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 17, 2020 11:21 AM

All replies

  • User-1330468790 posted

    Hi Nirvriti Sharma, 

     

    Could you please specify what the problem is?

    The codes are correct generally. I think you might have a problem about displaying the image. That way, we might need to dig more for storing the image.

    If you upload the image to the server and store the path of the image in the database, then you just need to confirm the path is correct. 

    However, if you store the image with binary/based64 encoded format in database, you might need to add a prefix "data:image/png;base64, " as below.

    imgPhoto.ImageUrl = "data:image/png;base64," + base64string;

     

    Hope this can help you.

    Best regards,

    Sean

    Thursday, August 6, 2020 3:04 AM
  • User-1330468790 posted

    Hi Nirvriti Sharma,

     

    Have your problem solved?

    If you still have any problem, feel free to let me know.

     

    Best regards,

    Sean

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 17, 2020 11:21 AM
  • User186310208 posted

    Sean Fang

    thanx for the concern...but i solve this

    Monday, August 17, 2020 11:37 AM