two project in the same solution image url problem
I have two projects on my solution and I want to use other project pictures dynamically How can I link to other project picture (using imageurl property)
开发者_StackOverflowSystem.Web.UI.WebControls.Image imd = new System.Web.UI.WebControls.Image();
imd.Width = 220;
imd.Height = 215;
imd.ImageUrl = "~/Content/Images/Attachments/test.png;
pnlattachment.Controls.Add(imd);
To access an image from another project, you'd have to embed that image as an embedded resource into the assembly and access it using GetWebResourceUrl: http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getwebresourceurl.aspx
Or, if we are talking two web sites, you could use the ../../ notation to access the appropriate directory, since ~ only works in the context of the current virtual directory.
HTH.
精彩评论