image in datalist

Discussion in 'ASP .Net Datagrid Control' started by mahsa, May 2, 2004.

  1. mahsa

    mahsa Guest

    hi I use the image in datalis
    <asp:Imag
    ImageUrl='<%#Server.MapPath(@"\images\roomscenes\"+DataBinder.Eval(Container.DataItem, "PartNo")+"_ss.jpg") %>' Visible='<%#!System.IO.File.Exists(@"\images\roomscenes\"+DataBinder.Eval(Container.DataItem, "PartNo")+"_ss.jpg") %>' runat="server" ID="Image1" /
    but it always return visible=fals
    when i use
    FileInfo fi = new FileInfo(Server.MapPath(@"\images\roomscenes\"+strFileName+"_ss.jpg"))
    if (fi.Exists
    {do some thing
    it shows the currect answer how can I use it in image tag?
     
    mahsa, May 2, 2004
    #1
    1. Advertising

  2. Don't use MapPath. Because MapPath returns phisical path and you need to get
    to virtual path. It's a different.

    /// <summary>

    /// Returns Phisical path. E.g.: c:\intepub\wwwroot\test\

    /// </summary>

    public static string PhisicalPath

    {

    get

    {

    return
    System.Web.HttpContext.Current.Request.MapPath(HttpContext.Current.Request.A
    pplicationPath + "/");

    }

    }

    /// <summary>

    /// Gets Virtual Directory of the application

    /// E.g: microsoft/

    /// </summary>

    public static String AppVirtualDir //returns virtual directory

    {

    get

    {

    return HttpContext.Current.Request.ApplicationPath + '/';

    }

    }

    /// <summary>

    /// Gets the host of the application

    /// E.g.: Server2

    /// </summary>

    public static String AppHost //returns host

    {

    get

    {

    return HttpContext.Current.Request.Url.Host;

    }

    }

    /// <summary>

    /// Returns "http://"

    /// </summary>

    public static String AppProtocol //returns protocol

    {

    get

    {

    return "http://";

    }

    }


    /// <summary>

    /// Gets the absolute root of the application

    /// E.g.: http://server2/microsoft/

    /// </summary>

    public static String AppAbsoluteRoot //returns the whole path

    {

    get

    {

    return AppProtocol + AppHost + AppVirtualDir;

    }

    }


    "mahsa" <> wrote in message
    news:...
    > hi I use the image in datalist
    > <asp:Image
    >

    ImageUrl='<%#Server.MapPath(@"\images\roomscenes\"+DataBinder.Eval(Container
    ..DataItem, "PartNo")+"_ss.jpg") %>'
    Visible='<%#!System.IO.File.Exists(@"\images\roomscenes\"+DataBinder.Eval(Co
    ntainer.DataItem, "PartNo")+"_ss.jpg") %>' runat="server" ID="Image1" />
    > but it always return visible=false
    > when i use
    > FileInfo fi = new

    FileInfo(Server.MapPath(@"\images\roomscenes\"+strFileName+"_ss.jpg"));
    > if (fi.Exists)
    > {do some thing}
    > it shows the currect answer how can I use it in image tag?
     
    Michael Tkachev, May 5, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gönen EREN

    Datalist in Datalist How?

    Gönen EREN, Aug 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    413
    Gönen EREN
    Aug 22, 2003
  2. acko bogicevic

    DataList in DataList

    acko bogicevic, Nov 10, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,517
    acko bogicevic
    Nov 11, 2003
  3. Steve Lloyd
    Replies:
    1
    Views:
    706
    Rick Spiewak
    May 26, 2004
  4. Nevyn Twyll
    Replies:
    8
    Views:
    1,882
  5. Luis Esteban Valencia
    Replies:
    1
    Views:
    493
    John Saunders
    Jan 6, 2005
Loading...

Share This Page