从代码更改页面bgcolor(重新发布) [英] Changing page bgcolor from code (repost)

查看:62
本文介绍了从代码更改页面bgcolor(重新发布)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在原帖中我失败了所以表明我正在使用框架

1.1 .......


我需要能够从代码更改页面的背景颜色。我在另一个来自Peter Huang的论坛中找到了这个问题的答案。

表示id =" bg"如下......


< body MS_POSITIONING =" GridLayout" RUNAT = QUOT;服务器" id =" bg">


然后我们可以在我们的代码隐藏文件中执行以下操作....


Private Sub Page_Load( sender As Object,e As System.EventArgs)

bg.Attributes.Add(" BgColor","#ff9933")

End Sub


但是,我得到的错误是bg是私有的。


有没有解决这个问题的方法,其中bgcolor和
$的其他属性b $ b文件可以从代码隐藏代码更改吗?

-

问候,

Gary Blakely

In the original post I failed so indicate that I am using framework
1.1.......

I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

Private Sub Page_Load(sender As Object, e As System.EventArgs)
bg.Attributes.Add("BgColor", "#ff9933")
End Sub

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of the
document can be changed from codebehind code?
--
Regards,
Gary Blakely

推荐答案

如果这就是你想要做的全部,为什么不做这件事,

通过设置< body background-color ...>属性?


你不是真的想要改变代码的背景颜色

。你只是设置一个任意的背景颜色。


如果这就是你想做的全部,为什么不把它设置在< body ...> ;


否则,请使用我发布的示例代码。

这些示例允许用户选择您想要允许的任何背景/前景色。 />

Juan T. Llibre,asp.net MVP

aspnetfaq.com: http://www.aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol:< a rel =nofollowhref =http://asp.net.do/foros/target =_ blank> http://asp.net.do/foros/

===================================

" GaryDean" <嘎****** @ newsgroups.nospam>写在消息

新闻:eX ************** @ TK2MSFTNGP14.phx.gbl ...
If that''s all you want to do, why don''t you simply do it,
by setting the <body background-color...> attribute ?

You aren''t *really* attemptiong to change the background color
from code. You are just setting an arbitrary background color.

If that''s all you want to do, why don''t you just set it in the <body...>

Otherwise, use the code for the examples I posted.
Those samples allow users to select any background/foreground colors you want to allow.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"GaryDean" <Ga******@newsgroups.nospam> wrote in message
news:eX**************@TK2MSFTNGP14.phx.gbl...
在原帖中我失败,所以表明我正在使用框架1.1 .......

我需要能够从代码中更改页面的背景颜色。我在另一个来自Peter Huang的论坛中找到了这个问题的答案,他说这是一个id =" bg"如下......

< body MS_POSITIONING =" GridLayout" RUNAT = QUOT;服务器" id =" bg">

然后我们可以在我们的代码隐藏文件中执行以下操作....

Private Sub Page_Load(发件人作为对象,e作为系统。 EventArgs)
bg.Attributes.Add(" BgColor","#ff9933")
End Sub

然而,我得到的错误是bg是私有的。

是否有解决此问题的方法,其中bgcolor和
文档的其他属性可以从代码隐藏代码更改?

-
问候,
Gary Blakely
In the original post I failed so indicate that I am using framework 1.1.......

I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

Private Sub Page_Load(sender As Object, e As System.EventArgs)
bg.Attributes.Add("BgColor", "#ff9933")
End Sub

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of the
document can be changed from codebehind code?
--
Regards,
Gary Blakely



是的我真的想在运行时设置它 - 请相信我。不是

设计时间。


之所以我不是简单地将它设置在体内是因为我想设置它

在运行时。


您的示例显示它正常工作,但我看不到您的代码。


也许我们沟通不畅。我想了解如何在运行时从我的代码隐藏文件中设置

背景颜色。

-

问候,

Gary Blakely

Juan T. Llibre <无*********** @ nowhere.com>在消息中写道

新闻:Og ************** @ TK2MSFTNGP09.phx.gbl ...
Yes I REALLY want to set it at run time - please trust me on this. Not at
design time.

The reason why I don''t simply set it in the body is because I want to set it
at run time.

your examples show it working but I can''t see your code behind.

Maybe we are not communicating well. I want to find out how to set the
background color at run time from my code behind file.
--
Regards,
Gary Blakely
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...
如果那是''s所有你想做的,为什么不简单地做,
设置< body background-color ...>属性?

你不是真的想从代码中改变背景颜色。你只是设置一个任意的背景颜色。

如果这就是你想要做的全部,为什么不把它设置在< body ...>

否则,请使用我发布的示例代码。
这些示例允许用户选择您想要允许的任何背景/前景颜色。

Juan T .Llibre,asp.net MVP
aspnetfaq.com: http://www.aspnetfaq。 com /
asp.net faq: http:// asp。 net.do/faq/
foros de asp.net,en espa?ol: http://asp.net.do/foros/
========================== =========
GaryDean <嘎****** @ newsgroups.nospam>在消息中写道
新闻:eX ************** @ TK2MSFTNGP14.phx.gbl ...
If that''s all you want to do, why don''t you simply do it,
by setting the <body background-color...> attribute ?

You aren''t *really* attemptiong to change the background color
from code. You are just setting an arbitrary background color.

If that''s all you want to do, why don''t you just set it in the <body...>

Otherwise, use the code for the examples I posted.
Those samples allow users to select any background/foreground colors you
want to allow.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"GaryDean" <Ga******@newsgroups.nospam> wrote in message
news:eX**************@TK2MSFTNGP14.phx.gbl...
在原帖中我失败了所以表明我正在使用框架
1.1 .......

我需要能够从代码中更改页面的背景颜色。我在Peter Huang的另一个论坛上找到了这个问题的答案,

id =" bg"如下......

< body MS_POSITIONING =" GridLayout" RUNAT = QUOT;服务器" id =" bg">

然后我们可以在我们的代码隐藏文件中执行以下操作....

Private Sub Page_Load(发件人作为对象,e作为系统。 EventArgs)
bg.Attributes.Add(" BgColor","#ff9933")
End Sub

然而,我得到的错误是bg是私有的。

是否有解决此问题的方法可以从代码隐藏代码更改bgcolor和
文档的其他属性?

-
问候,
Gary Blakely
In the original post I failed so indicate that I am using framework
1.1.......

I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that
said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

Private Sub Page_Load(sender As Object, e As System.EventArgs)
bg.Attributes.Add("BgColor", "#ff9933")
End Sub

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of
the
document can be changed from codebehind code?
--
Regards,
Gary Blakely




re:
你的例子显示它工作,但我看不到你的代码。


会话的代码位于:
http://samples.gotdotnet.com/quickst。 ..ze.aspx& font = 3


并且,对于使用cookie的代码,代码位于:
http://samples.gotdotnet .com / quickst ... 1 / cookies1.src


Juan T. Llibre,asp.net MVP

aspnetfaq .com: http://www.aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

==================== ===============

" GaryDean" <嘎****** @ newsgroups.nospam>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP14.phx.gbl ...是的我真的想在运行时设置它 - 请相信我。不是在设计时。

我之所以不把它放在体内是因为我想在运行时设置它。

你的例子显示它工作,但我看不到你的代码。

也许我们沟通不好。我想知道如何在我的代码后面的文件中设置运行时的背景颜色。

-
问候,
Gary Blakely
Juan T. Llibre <无*********** @ nowhere.com>在消息中写道
新闻:Og ************** @ TK2MSFTNGP09.phx.gbl ...
your examples show it working but I can''t see your code behind.
The code for with sessions is at :
http://samples.gotdotnet.com/quickst...ze.aspx&font=3

and, for doing it with cookies, the code is at :
http://samples.gotdotnet.com/quickst...1/cookies1.src


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"GaryDean" <Ga******@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... Yes I REALLY want to set it at run time - please trust me on this. Not at design time.

The reason why I don''t simply set it in the body is because I want to set it at run time.

your examples show it working but I can''t see your code behind.

Maybe we are not communicating well. I want to find out how to set the background color at run
time from my code behind file.
--
Regards,
Gary Blakely
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:Og**************@TK2MSFTNGP09.phx.gbl...
如果这就是你想要的全部做,为什么不简单地这样做,
设置< body background-color ...>属性?

你不是真的想从代码中改变背景颜色。你只是设置一个任意的背景颜色。

如果这就是你想要做的全部,为什么不把它设置在< body ...>

否则,请使用我发布的示例代码。
这些示例允许用户选择您想要允许的任何背景/前景颜色。

Juan T. Llibre,asp .net MVP
aspnetfaq.com: http://www.aspnetfaq.com/
asp.net常见问题: http://asp.net.do/ faq /
foros de asp.net,en espa?ol: http://asp.net.do/foros/
============================== =====
GaryDean <嘎****** @ newsgroups.nospam>在消息中写道
新闻:eX ************** @ TK2MSFTNGP14.phx.gbl ...
If that''s all you want to do, why don''t you simply do it,
by setting the <body background-color...> attribute ?

You aren''t *really* attemptiong to change the background color
from code. You are just setting an arbitrary background color.

If that''s all you want to do, why don''t you just set it in the <body...>

Otherwise, use the code for the examples I posted.
Those samples allow users to select any background/foreground colors you want to allow.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"GaryDean" <Ga******@newsgroups.nospam> wrote in message
news:eX**************@TK2MSFTNGP14.phx.gbl...
在原帖中我失败了所以表明我正在使用框架1.1 .......

我需要能够从代码中更改页面的背景颜色。我在另一个来自Peter Huang的论坛中找到了这个问题的答案,他说这是一个id =" bg"如下......

< body MS_POSITIONING =" GridLayout" RUNAT = QUOT;服务器" id =" bg">

然后我们可以在我们的代码隐藏文件中执行以下操作....

Private Sub Page_Load(发件人作为对象,e作为系统。 EventArgs)
bg.Attributes.Add(" BgColor","#ff9933")
End Sub

然而,我得到的错误是bg是私有的。

是否有解决此问题的方法,其中bgcolor和
文档的其他属性可以从代码隐藏代码更改?

-
问候,
Gary Blakely
In the original post I failed so indicate that I am using framework 1.1.......

I need to be able to change the background color of a page from code. I
found an answer to this question in another forum from Peter Huang that said
that an id="bg" as follows...

<body MS_POSITIONING="GridLayout" runat="server" id="bg">

then we could do the following in our codebehind file....

Private Sub Page_Load(sender As Object, e As System.EventArgs)
bg.Attributes.Add("BgColor", "#ff9933")
End Sub

However, I get the errror that bg is Private.

Is there a solution to this issue where bgcolor, and other attributes of the
document can be changed from codebehind code?
--
Regards,
Gary Blakely



这篇关于从代码更改页面bgcolor(重新发布)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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