Solved

pictures display in design mode but not browser visual studio

Posted on 2009-07-12
31
521 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now