从内容页面调用body标签 [英] call body tag from content page

查看:104
本文介绍了从内容页面调用body标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



我有一个带有body标签的母版页如下:

Hi Experts,

I have a master page with body tag looks like this:

<body  runat="server" id="pageBody">





我需要根据用户选择从下拉列表中更改正文背景图像。

所以我在后面的内容页面代码中调用了主页正文标记(dropdownlist selectedIndexChanged),如下所示: br />



I need to change the body background image according to user choice from dropdownlist.
So I called master page body tag in content page code behind (dropdownlist selectedIndexChanged) like the following:

HtmlGenericControl body = HtmlGenericControl)Master.FindControl("pageBody");



然后我做了以下更改背景属性:


and then i did the following to change the background attribute:

body.Attributes["style"] = "background: url('img/ic-vehicles/" + year_reg.SelectedItem.Text + "-" + make_reg.SelectedItem.Text + "-" + model_reg.SelectedItem.Text + "-" + trim + ".jpg') center center no-repeat ;background-attachment: fixed;";</pre>



背景不变!

我使用此代码确保路径正确:


The background is not changing!
I made sure the path is correct using this code:

bool isexist = File.Exists(Server.MapPath("img/ic-vehicles/" + year_reg.SelectedItem.Text + "-" + make_reg.SelectedItem.Text + "-" + model_reg.SelectedItem.Text + "-" + trim + ".jpg"));





编辑 :忘了说当我提出断点时我看到了这个例外:



EDIT: forgot to say when I put break point i see this exception:

base {System.Web.UI.HtmlControls.HtmlContainerControl} = {InnerText = '((System.Web.UI.HtmlControls.HtmlContainerControl)(((System.Web.UI.HtmlControls.HtmlGenericControl)(body)))).InnerText' threw an exception of type 'System.Web.HttpException'}



有什么建议吗?



谢谢


Any suggestions?

Thank you

推荐答案

没有召唤标签这样的概念。使用JavaScript,您可以随时通过更改其样式来更改正文背景。例如:

There is no such concept as "call a tag". With JavaScript, you can change the body background by changing its style at any time. For example:
document.body.style.background = "#faa85b url('background.png')";





-SA


这篇关于从内容页面调用body标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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