• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

asp.net mvc

Hi Guys,

I got confuse of how to display images through my database to the image path:

Here is what I'm trying to do.

Actually what I'm doing - i'm passing id to the controller and popup the window below:
function Showitems(id) {
            var url = "@System.Configuration.ConfigurationManager.AppSettings["webUrl"]";
            url = url + "Inventory/Itemsrefer/" + id;
            window.open(url, '_blank',"width=1200, height=800", 'resizable=No');
        }

Open in new window


"WebUrl" in web.config = <add key="webUrl" value="http://testerp.alt.com/" />

This is my popup window where the image should come up:



@{
    ViewBag.Title = "Picture";
    Layout = null;
}

@model ALThompsonCRM.Models.ViewModel.ItemPic

<center>
    <div>
        <td>
            <div id="divMyTags">
                <div class="existingTag">
                    <a class="closeButton" href="#" onclick="deleteme(@Model.picid);"></a>
                    <img alt="@Model.itemTitle" width="300" height="300" id="@Model.itemID" src="http://http://testerp.alt.com/doc/item_pics/@Model.picName" />
                </div>
            </div><br />
            @*<a href="#" onclick="makememain(@Model.picid)">Make this main picture</a>*@
        </td>

    </div>
</center>

Open in new window



I have database that much between item number to picture name which located in some path that i have access to.

Here is my server side code which I really don't know what i did:):
  public ActionResult Picture(int id)
        {
            ALThompsonCRMEntities db = new ALThompsonCRMEntities();
            ItemPic objpic = new ItemPic();
            var img = db.t_Item_Picture.Where(p => p.ItemId == id);

            if (id != null)
            {
                string docPath = ConfigurationManager.AppSettings["docPath"].ToString();

            }

            return View(objpic);

        }

Open in new window


Thanks ,
0
Moti Mashiah
Asked:
Moti Mashiah
1 Solution
 
Moti Mashiah.NET DeveloperAuthor Commented:
Solved the issue:

Here is the solution
 public ActionResult Picture(int id)
        {
            ALThompsonCRMEntities _db = new ALThompsonCRMEntities();
            var ip = _db.t_Item_Picture.Where(p => p.ItemId == id).Select(p => new ItemPic { picid = p.Id, picName = p.Pic_Name, itemTitle = p.Item_Title, itemID = p.ItemId }).ToList();
            ItemPic ipc = new Models.ViewModel.ItemPic();
            ipc.itemID = id;
            ipc.lstPics = ip;
            if (ip.Count <= 0)
            {
                rmsmasterdbtestEntities _rms = new rmsmasterdbtestEntities();
                var im = _rms.Items.Where(p => p.ID == id).FirstOrDefault();
                ipc.itemTitle = im.Description;
                ipc.picName = im.PictureName;
            }
            else
            {
                int i = 0;
                foreach (var itm in ip)
                {
                    if (i == 0)
                    {
                        ipc.itemTitle = itm.itemTitle;
                        ipc.picName = itm.picName;
                        i = 1;
                    }
                }
            }

            return View(ipc);
        }

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now