Reputation: 13
I m fetching the image name path from vb.net and want to pass it to image URL in asp.net.. How to do... I m doing this but display nothing IN Vb.net
dim myLogo as string = ResolveUrl("C:\Test\Logo\" & img_name)
Me.DataBind()
IN ASP.net
<asp:Image ID="test" ImageUrl='<% myLogo %>' runat="server" Height="100px" Width="100px" />
Upvotes: 0
Views: 7488
Reputation: 320
You need to declare myLogo variable as protected in general section of code and in aspx page you can use folling code to bind imageurl.
<asp:image runat="server" Height="100px" Width="100px" imageurl='<%#myLogo%>' />
Please let me know if this does not work.
Upvotes: 0
Reputation: 3297
Try this
<asp:Image ID="test" ImageUrl='<%= myLogo %>' runat="server" Height="100px" Width="100px" />
Upvotes: 0
Reputation: 16134
ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root.
The following example shows the ~ operator used to specify a root-relative path for an image when using the Image server control In this example, the image file is read from the Images folder that is located directly under the root of the Web application, regardless of where in the Web site the page is located.
<asp:image runat="server" id="Image1"
ImageUrl="~/Images/SampleImage.jpg" />
You can use the ~ operator in any path-related property in server controls. The ~ operator is recognized only for server controls and in server code. You cannot use the ~ operator for client elements.
For more details refer:
Eg.
dim myLogo as string = "~\Logo\" & img_name
Upvotes: 2
Reputation: 27322
Surely the url to the file will be:
"file://c:\Test\Logo\" & img_name
Have you tried that?
Upvotes: 0