在ASP中显示图像:标签不起作用 [英] Displaying image in ASP:label not working

查看:62
本文介绍了在ASP中显示图像:标签不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建人们在访问该页面时看到的成员个人资料页面。一切都很好,除了阿凡达。



代码示例

imagePath =app_images / faces /& (MemberAvatar)

Label1.Text = String.Format(< img src ='app_images / faces / {0}'style ='width:200px; height:200px;'/> ;,imagePath)



图像的字段显示(尽管没有图像),但我不能为我这样的人获得成员头像显示。 br />


我尝试过:



Profile.aspx

I am trying to build the member profile page people see when they visit the page. Everything works fine except the Avatar.

Code Sample
imagePath = "app_images/faces/" & ("MemberAvatar")
Label1.Text = String.Format("<img src='app_images/faces/{0}' style='width: 200px; height: 200px;'/>", imagePath)

The field for the image is showing (no image though), but I cannot for the likes of me get the members avatar to display.

What I have tried:

Profile.aspx

<div>
  <h2 style="text-align: center;">Member Profile</h2>

  Name <asp:Label ID="mname" runat="server"></asp:Label><br />
  Points <asp:Label ID="mPoints" runat="server"></asp:Label><br />
  My Email <asp:Label ID="mEmail" runat="server"></asp:Label><br />
  About Me <asp:Label ID="mAbout" runat="server"></asp:Label><br />
  City <asp:Label ID="mCity" runat="server"></asp:Label><br />
  State <asp:Label ID="mState" runat="server"></asp:Label><br />
  Country <asp:Label ID="mCountry" runat="server"></asp:Label><br />
  Patient Type <asp:Label ID="mPatient" runat="server"></asp:Label><br />
  My Issues <asp:Label ID="mIssues" runat="server"></asp:Label><br />


  My Ava









Profile.aspx.vb







Profile.aspx.vb

Imports System.Data.OleDb
Imports System.Data

Partial Class Profile
    Inherits System.Web.UI.Page

    Dim pointDs As OleDbDataAdapter
    Dim mymemDs As OleDbDataAdapter
    Dim con As OleDbConnection
    Dim ds As New DataTable
    Dim imagePath As String


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        con = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0 ;data source=" & Server.MapPath("app_data/SimpleQSet.mdb") & ";")
        If Request.QueryString("mem") <> "" Then
            pointDs = New OleDbDataAdapter("select * from PointsProfile where Member='" & Request.QueryString("mem") & "'", con)
        ElseIf Session("member") <> "" Then
            pointDs = New OleDbDataAdapter("select * from PointsProfile where Member='" & Session("member") & "'", con)
        Else
            Response.Redirect("Mainforum.aspx")
            Exit Sub
        End If

        pointDs.Fill(ds)

        mname.Text = ds.Rows(0)(0)
        mPoints.Text = ds.Rows(0)(1)
        mEmail.Text = ds.Rows(0)(3)
        mAbout.Text = ds.Rows(0)(5)
        mCity.Text = ds.Rows(0)(6)
        mState.Text = ds.Rows(0)(7)
        mCountry.Text = ds.Rows(0)(8)
        mPatient.Text = ds.Rows(0)(9)
        mIssues.Text = ds.Rows(0)(10)

        imagePath = "app_images/faces/" & ("MemberAvatar")
        Label1.Text = String.Format("<img src='app_images/faces/{0}' style='width: 200px; height: 200px;'/>", imagePath)
 

        con.Close()
    End Sub
End Class

推荐答案

Label1.Text = String.Format("<img src='app_images/faces/{0}' style='width: 200px; height: 200px;'/>", imagePath)



如您的代码所示,标签仅用于文本,而不是图像。您需要使用图像控制 [ ^ ]而不是。


As your code indicates, a Label is for text only, not images. You need to use an Image Control[^] instead.


这篇关于在ASP中显示图像:标签不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆