简体   繁体   English

vb.net中的Directcast

[英]directcast in vb.net

i have 1 a.master page and 1 b.aspx with its b.aspx.vb page. 我有1个a.master页面和1个b.aspx及其b.aspx.vb页面。 I have the following property in the a.master.vb 我在a.master.vb中具有以下属性

Public Property Page_Title() As String
    Get
        Return title_div.InnerHtml
    End Get
    Set(ByVal value As String)
        title_div.InnerHtml = value
    End Set
End Property

in the b.aspx.vb page i have 在b.aspx.vb页面中

DirectCast(Page.Master, a_am).Page_Title = "/images/img1.png"

but when i open the a.aspx page, it shows the text /images/img1.png and not the image. 但是当我打开a.aspx页面时,它显示文本/images/img1.png而不是图像。 how do i make it show that image i want 我如何使它显示我想要的图像

You've told it to make the InnerHtml just the string "/images/img1.png" - how did you expect that to be automatically translated into an image tag? 您已经告诉它使InnerHtml只是字符串“ /images/img1.png”-您如何期望将其自动转换为图像标签? Try this: 尝试这个:

DirectCast(Page.Master, a_am).Page_Title = "<img src='/images/img1.png' />"

For the sake of accessibility etc you should really have some "alt" text etc, mind you... 为了便于访问等,您应该确实有一些“ alt”文本等,请注意...

您要将html添加到页面中,因此需要将有效的html放入字符串中:

DirectCast(Page.Master, a_am).Page_Title = "<img src='/images/img1.png' />"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM