image from folder

5 posts, 1 answers
  1. rastin
    rastin avatar
    14 posts
    Member since:
    May 2011

    Posted 01 Jun 2011 Link to this post

    hi all
    i want read all of my fields of table and in each record have an image button that show image that its name is "~\Image\"+fieldname(one of table field).
    how can do this?
    thankful.
  2. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 01 Jun 2011 Link to this post

    Hi Rastin,

    Which RadControls are you using? Do you just need to know how to set a button image dynamically.

    -Gimmik
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. rastin
    rastin avatar
    14 posts
    Member since:
    May 2011

    Posted 02 Jun 2011 Link to this post

    Hi Gimmik
    i used RadListView
    thankful.
  5. Answer
    Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 03 Jun 2011 Link to this post

    Hi Rastin,

    I've been looking into the issue. This should be possible to do. I think the key is going to be wiring-up the PreRender event for the RadImageButton to set the ImageURL. You'll have to access the cell in whichever RadControl you are using that contains the file name for the image. I made an example using a RadGrid. The file name is in column 0, and that file name is used to create the URL for the RadImageButton which is in column 1 of the same row.

    I hope this is clear - let me know if you have questions.
    -Gimmik

    protected void RadButton1_OnPreRender(object sender, EventArgs e)
    {
        RadButton btn = (sender as RadButton);
     
        GridDataItem dataItem = btn.Parent.Parent as GridDataItem;
     
        String filename = dataItem["filename"].Text;
        String fullPath = "~/Image/" + filename;
        btn.Image.ImageUrl = fullPath;
    }
  6. rastin
    rastin avatar
    14 posts
    Member since:
    May 2011

    Posted 03 Jun 2011 Link to this post

    very thankful Gimmik for your help.
    thankful.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017