在default.aspx上显示Master页面的图像 [英] Displaying image of Master page on default.aspx

查看:72
本文介绍了在default.aspx上显示Master页面的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的项目有问题。问题是: -

我制作母版页并在div中设置背景图像。在另一个表单上加载主页面图像显示但在运行时图像不显示。

Plz为此提供任何解决方案。

Hi,
I have a problem in my project.the problem is as:-
I make a Master page and in a div set a background image.After loading the master page on another form the image display but at run time Image is not displaying.
Plz give any solution for this.

推荐答案

要从内容页面中的代码访问母版页的方法和属性,可以使用FindControl方法:

To access the methods and properties of a master page from code in a content page, you can use the FindControl method:
Image imgOnMasterPage = (Image)
  (this.Master.FindControl ("ImageName"));
if(imgOnMasterPage != null)
{
//    Do as your wish
}


如果如果您正在使用图像服务器控件,或者通过代码将图像放在页面上,则应使用〜/语法引用图像以引用应用程序根目录。因此,如果图像位于应用程序目录结构的根目录中,则可以通过〜/ logo.gif引用它。如果你将它存储在名为images的文件夹中,你可以使用〜/ images / logo.gif等。
If you are using the Image server control, or placing the images on your page through your code behind, you should reference the images using the "~/" syntax to refer to the application root. So if the image is in the root of your application's directory structure you could reference it through "~/logo.gif". If you had it stored in a folder called "images" you would use "~/images/logo.gif", etc.


你可以在你的应用程序中创建一个文件夹作为Image您在主页面中的图像采用Div标签中的Image控件。

现在根据您的选择设置Image Control的属性,但要注意ImageUrl属性。

< asp:图片ID =横幅宽度=100%高度=100pxrunat =服务器ImageUrl =〜/ image / your.jpg/>
U can create a folder as Image in your application now place your images in that in master page take an Image control in Div tag as u have taken.
Now set the properties of Image Control as per your choice but pay attention on ImageUrl property.
<asp:Image ID="Banner" Width="100%" Height="100px" runat="server" ImageUrl="~/image/your.jpg" />


这篇关于在default.aspx上显示Master页面的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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