Solved

pictures display in design mode but not browser visual studio

Posted on 2009-07-12
31
569 Views
Last Modified: 2013-12-26
I have been trying to setup images in a vb.net application. I can see the images when in design mode but when I hit f5 to view in a browser the images do not show only the red X with the alt tag. I don't know what I am missing.

I'm using visual studio 2005 and my OS is Vista

Thanks for any help
0
Comment
Question by:OrionsX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 10
  • 2
  • +2
31 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24835108
What path do you use for the pictures ?
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24835130
hi OrionsX,
       
                Check it , i hope it will work.
<img runat="server" src="~/image/photo-small.jpg" class="photosmall" width="150"
                    height="100" alt="Write a short description of the image here. It will show if the imageis not loaded. Non visual browsers and search engines will also read this text."
                    title="Users will see this text when they roll over this image. Non-visual browsers will read this text to blind users." />

Open in new window

0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24835135
<img runat="server" src="~/image/photo-small.jpg" class="photosmall" width="150"
                    height="100" alt="Write a short description of the image here. It will show if the imageis not loaded. Non visual browsers and search engines will also read this text."
                    title="Users will see this text when they roll over this image. Non-visual browsers will read this text to blind users." />


========================

"~/image/photo-small.jpg" = path, you choose your path accordingly.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:OrionsX
ID: 24835385
jp,

I use  <img alt="header" src="App_Data/header.jpg" style="z-index: 112; left: 0px; position: absolute;
            top: 0px" /> to call the pic.

tapan,

I tried to use <img alt="header" src="~/App_Data/header.jpg" style="z-index: 112; left: 0px; position: absolute;
            top: 0px" />
but the pic wouldn't display in design mode or the browser.

Am I missing something in IIS maybe?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24835398
>> but the pic wouldn't display in design mode or the browser.
But it shows when you run it, right ?
0
 
LVL 5

Author Comment

by:OrionsX
ID: 24835399
...FYI...I originally tried to setup a master page but encountered this problem. I then decided to try to just place a pic on the page to see if I could at least do that but found that I couldn't.  I do eventually want to use a master page for the pics, but want to first find out why the pics aren't displaying...
0
 
LVL 5

Author Comment

by:OrionsX
ID: 24835413
jp,

No I get nothing when I use ~/ before the source path (<img alt="header" src="~/App_Data/header.jpg....)

When I use (<img alt="header" src="App_Data/header.jpg....), I see the pic in design mode but not when I run it...
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24835435
hi OrionsX,

               Use src="../App_Data/header.jpg"   and check this and post your comment.


I am waiting for your replay.





0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24835574
hi OrionsX,

                 Try the below code and post your replay.

<img alt="header" runat="server" src="../App_Data/header.jpg" style="z-index: 112; left: 0px; position: absolute;top: 0px" />


thanks.
0
 
LVL 5

Author Comment

by:OrionsX
ID: 24835627
tapan,

still nothing... in neither design nor run mode

I'm starting to think it is an IIS setting or other config issue but I have not a clue
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24835636
can you post your code ?
0
 
LVL 5

Author Comment

by:OrionsX
ID: 24838256
My .Net code is below, Ill post the code behind in the next pane:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server"
            Style="z-index: 100; left: 256px;
            position: absolute; top: 240px"
            Text="Email Address:"></asp:Label>
        <asp:Label ID="Label2" runat="server"
            Style="z-index: 101; left: 280px;
            position: absolute; top: 272px"
            Text="Password:"></asp:Label>
        <asp:TextBox ID="txtUserID" runat="server"
            Style="z-index: 102; left: 360px;
            position: absolute; top: 240px" Width="144px"></asp:TextBox>
        <asp:TextBox ID="txtPassword" runat="server"
            Style="z-index: 103; left: 360px;
            position: absolute; top: 272px"
            TextMode="Password" TabIndex="1" Width="144px"></asp:TextBox>
        <asp:Button ID="btLogin" runat="server"
            Style="z-index: 104; left: 320px;
            position: relative; top: 296px"
            Text="Login" TabIndex="2" />
        <asp:Label ID="Label3" runat="server"
            Font-Bold="True" ForeColor="Red"
            Style="z-index: 105; left: 520px;
            position: absolute; top: 256px"
            Text="Label" Visible="False"></asp:Label>
        <asp:Button ID="btReset" runat="server"
            Style="z-index: 106; left: 328px;
            position: relative; top: 296px"
            Text="Reset" TabIndex="3" />
        <asp:HyperLink ID="HyperLink1"
            runat="server" NavigateUrl="~/register.aspx"
            Style="z-index: 107; left: 328px;
            position: absolute; top: 352px" TabIndex="4">Click here to register.</asp:HyperLink>
        <asp:Label ID="Label4" runat="server"
            Font-Bold="True" Style="z-index: 108;
            left: 176px; position: absolute;
            top: 200px" Text="To login, enter your email address and password you used to register."></asp:Label>
        <asp:RegularExpressionValidator
            ID="RegularExpressionValidator1"
            runat="server" ControlToValidate="txtUserID"
            ErrorMessage="Not a valid Email Address"
            Font-Bold="True" Style="z-index: 109;
            left: 520px; position: absolute;
            top: 240px" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">Not a valid Email Address</asp:RegularExpressionValidator>
        <asp:RegularExpressionValidator
            ID="RegularExpressionValidator3"
            runat="server" ControlToValidate="txtPassword"
            ErrorMessage="Password can only be letters or numbers!"
            Font-Bold="True" Style="z-index: 110;
            left: 520px; position: absolute;
            top: 280px" ValidationExpression="^[a-zA-Z0-9]*"></asp:RegularExpressionValidator>
        &nbsp;
        <img alt="header" src="App_Data/header.jpg" style="z-index: 112; left: 0px; position: absolute;
            top: 0px" />
    
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 5

Author Comment

by:OrionsX
ID: 24838264
...code-behind...
Imports Microsoft.Data.Odbc
Imports System.Web.UI
Imports System.Data.Odbc
 
 
Public Class _Default
    Inherits System.Web.UI.Page
 
    Dim conn As New conn
    Public DBCON1 As String = ConfigurationSettings.AppSettings("connstring")
 
    Protected Sub btLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btLogin.Click
 
        Dim druser As Data.OleDb.OleDbDataReader
        Dim sqlstr As String
 
        If txtUserID.Text <> "" And txtPassword.Text <> "" Then
 
            sqlstr = "SELECT user_id, passW, first_n FROM userTB WHERE user_id ='" & txtUserID.Text & "' AND passW ='" & txtPassword.Text & "'"
 
            druser = conn.getOLEDBDR(DBCON1, sqlstr)
 
            While druser.Read
                ' valid user send to home page
                Session("userID") = druser(0)
                Session("password") = druser(1)
                Session("FName") = druser(2)
            End While
 
            If txtUserID.Text = Session("userID") And txtPassword.Text = Session("password") Then
                Response.Redirect("energyUsage.aspx")
            Else : Label3.Text = "Invalid Login!"
                Label3.Visible = True
 
            End If
 
            'If Session("userid") = 0 Then
            'Label3.Text = "Invalid Login"
            'txtUserID.Text = ""
            'txtPassword.Text = ""
            'End If
 
        Else
            Label3.Text = "Cannot accept blank fields"
            Label3.Visible = True
        End If
 
    End Sub
 
    Protected Sub btReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btReset.Click
        txtUserID.Text = ""
        txtPassword.Text = ""
        Response.Redirect("login.aspx")
    End Sub
End Class

Open in new window

0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24838373
hi OrionsX,

                  I have added this to your code and removing the other one

<asp:Image ID="Image1" runat="server" ImageUrl="~/App_Data/header.jpg" />

just copy paste the below code and mark the difference and replay me  and i am waiting for your replay.

       
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server"
            Style="z-index: 100; left: 256px;
            position: absolute; top: 240px"
            Text="Email Address:"></asp:Label>
        <asp:Label ID="Label2" runat="server"
            Style="z-index: 101; left: 280px;
            position: absolute; top: 272px"
            Text="Password:"></asp:Label>
        <asp:TextBox ID="txtUserID" runat="server"
            Style="z-index: 102; left: 360px;
            position: absolute; top: 240px" Width="144px"></asp:TextBox>
        <asp:TextBox ID="txtPassword" runat="server"
            Style="z-index: 103; left: 360px;
            position: absolute; top: 272px"
            TextMode="Password" TabIndex="1" Width="144px"></asp:TextBox>
        <asp:Button ID="btLogin" runat="server"
            Style="z-index: 104; left: 320px;
            position: relative; top: 296px"
            Text="Login" TabIndex="2" />
        <asp:Label ID="Label3" runat="server"
            Font-Bold="True" ForeColor="Red"
            Style="z-index: 105; left: 520px;
            position: absolute; top: 256px"
            Text="Label" Visible="False"></asp:Label>
        <asp:Button ID="btReset" runat="server"
            Style="z-index: 106; left: 328px;
            position: relative; top: 296px"
            Text="Reset" TabIndex="3" />
        <asp:HyperLink ID="HyperLink1"
            runat="server" NavigateUrl="~/register.aspx"
            Style="z-index: 107; left: 328px;
            position: absolute; top: 352px" TabIndex="4">Click here to register.</asp:HyperLink>
        <asp:Label ID="Label4" runat="server"
            Font-Bold="True" Style="z-index: 108;
            left: 176px; position: absolute;
            top: 200px" Text="To login, enter your email address and password you used to register."></asp:Label>
        <asp:RegularExpressionValidator
            ID="RegularExpressionValidator1"
            runat="server" ControlToValidate="txtUserID"
            ErrorMessage="Not a valid Email Address"
            Font-Bold="True" Style="z-index: 109;
            left: 520px; position: absolute;
            top: 240px" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">Not a valid Email Address</asp:RegularExpressionValidator>
        <asp:RegularExpressionValidator
            ID="RegularExpressionValidator3"
            runat="server" ControlToValidate="txtPassword"
            ErrorMessage="Password can only be letters or numbers!"
            Font-Bold="True" Style="z-index: 110;
            left: 520px; position: absolute;
            top: 280px" ValidationExpression="^[a-zA-Z0-9]*"></asp:RegularExpressionValidator>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/App_Data/header.jpg" /></div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24838417
these modified code given below working fine in my visual studio.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server"
            Style="z-index: 100; left: 256px;
            position: absolute; top: 240px"
            Text="Email Address:"></asp:Label>
        <asp:Label ID="Label2" runat="server"
            Style="z-index: 101; left: 280px;
            position: absolute; top: 272px"
            Text="Password:"></asp:Label>
        <asp:TextBox ID="txtUserID" runat="server"
            Style="z-index: 102; left: 360px;
            position: absolute; top: 240px" Width="144px"></asp:TextBox>
        <asp:TextBox ID="txtPassword" runat="server"
            Style="z-index: 103; left: 360px;
            position: absolute; top: 272px"
            TextMode="Password" TabIndex="1" Width="144px"></asp:TextBox>
        <asp:Button ID="btLogin" runat="server"
            Style="z-index: 104; left: 320px;
            position: relative; top: 296px"
            Text="Login" TabIndex="2" />
        <asp:Label ID="Label3" runat="server"
            Font-Bold="True" ForeColor="Red"
            Style="z-index: 105; left: 520px;
            position: absolute; top: 256px"
            Text="Label" Visible="False"></asp:Label>
        <asp:Button ID="btReset" runat="server"
            Style="z-index: 106; left: 328px;
            position: relative; top: 296px"
            Text="Reset" TabIndex="3" />
        <asp:HyperLink ID="HyperLink1"
            runat="server" NavigateUrl="~/register.aspx"
            Style="z-index: 107; left: 328px;
            position: absolute; top: 352px" TabIndex="4">Click here to register.</asp:HyperLink>
        <asp:Label ID="Label4" runat="server"
            Font-Bold="True" Style="z-index: 108;
            left: 176px; position: absolute;
            top: 200px" Text="To login, enter your email address and password you used to register."></asp:Label>
        <asp:RegularExpressionValidator
            ID="RegularExpressionValidator1"
            runat="server" ControlToValidate="txtUserID"
            ErrorMessage="Not a valid Email Address"
            Font-Bold="True" Style="z-index: 109;
            left: 520px; position: absolute;
            top: 240px" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">Not a valid Email Address</asp:RegularExpressionValidator>
        <asp:RegularExpressionValidator
            ID="RegularExpressionValidator3"
            runat="server" ControlToValidate="txtPassword"
            ErrorMessage="Password can only be letters or numbers!"
            Font-Bold="True" Style="z-index: 110;
            left: 520px; position: absolute;
            top: 280px" ValidationExpression="^[a-zA-Z0-9]*"></asp:RegularExpressionValidator>
        <asp:Image ID="Image1" runat="server" ImageUrl="~/App_Data/header.jpg" /></div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 5

Author Comment

by:OrionsX
ID: 24838537
Still nothing....could this be caused by a setting somewhere?
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24838607
hi OrionsX,

                Check the screen shot and the code is working fine.

Thanks.
frontEnd1.JPG
frontEnd2.JPG
0
 
LVL 5

Author Comment

by:OrionsX
ID: 24841171
I believe that the code works for you but I am having no luck on my end....that's why I'm wondering if there is a configuration setting that I am missing....
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24841752
if you attach your pages ( code pages ) then i will try for you?
0
 
LVL 5

Author Comment

by:OrionsX
ID: 24847875
Here you go...just remove the .doc extension at the end
login.aspx.doc
login.aspx.vb.doc
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 24847960
hi OrionsX,

I will suggest you,  use the "Request Attention" link for more help from other experts. They well help you and able to  solve your problem.  
Thanks,

Tapan pattanaik


0
 
LVL 5

Author Comment

by:OrionsX
ID: 24848697
Thanks for your help tapan, will do...
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24849376
1) HTML <img> tags are not server controls, and don't understand the root indicator (~).

2) You tried a server control (asp:Image), with the the root path indicator, and that didn't work.

3) It is starting to sound like an rights issue.  Test that theory by moving the images to the root folder.

4) What is the authentication mode?  Is this a Web Dev server or IIS web site?

0
 
LVL 5

Author Comment

by:OrionsX
ID: 24849847
TLO,

I have tried several different path declarations for the image so you may see some things that don't quite belong. The way it is now I still see the image in design mode but not at run-time

I have moved the images to the root but no luck

Authentication mode is <authentication mode="Windows"/>

This is an IIS site (Vista)

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24849981
How is the IIS web site directory security configured?
0
 
LVL 22

Expert Comment

by:cj_1969
ID: 24850088
If you want a directory off the root of the web site just start the path with a /
i.e.  <asp:Image ID="Image1" runat="server" ImageUrl="/App_Data/header.jpg" />

So ...
- if this is IIS then the root of IIS is typically c:\inetpub\wwwroot
- then your directory would be c:\inetpub\wwwroot\App_Data
- the file header.jpg would be in this directory
0
 
LVL 5

Accepted Solution

by:
OrionsX earned 0 total points
ID: 24854778
Hey guys I found the answer it is as follows:
Go to Control Panel -> Programs/Features - >Turn
Windows Features On/Off -> IIS -> WWW Services -> Common HTTP Featues ->
Static Content.  I had that turned off. Once I enabled it everone was happy
0
 
LVL 22

Expert Comment

by:cj_1969
ID: 24858751
I'm glad you found it.
That is supposed to be on by default.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question