I'm sure it's possible, but it hasn't occurred to me "how" to set the values
of the <body> tag via code-behind. I am currently setting the onload event i
n
the body tag of an ASP.NET web form using old-fashion asp type <%.. code...
%> blocks.
This "spaghetti-scripting" is difficult to manage, and is essentially a
hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
further causes problems when i try to wire events.
I tried, for example, to embbed an <asp:label /> and other controls in the
<body> tag, but VS.NET doesn't let me (probably for good reason too).
Anyone have ideas?
Thanks,<body id="body" runat="server">
codebehind:
protected body as HtmlGenericControl
Page_Load..
body.Attributes.Add("onLoad", "alert('Karl for the win!');")
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
values
> of the <body> tag via code-behind. I am currently setting the onload event
in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
values
> of the <body> tag via code-behind. I am currently setting the onload event
in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
Give the body an id and a runat=server. For example <body id=body1
runat=server>. In codebehind (vb) put
Protected body1 as htmlgenericcontrol in your declarations. Then you can set
any attribute that you can set in html. Here is an example of setting the
onload attribute.
body1.attributes("onload") ="java script:doSomething();return false;"
Mike
throw a RUNAT=SERVER in it and declare it in the codebehind. It should
work...
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"charliewest" <charliewest@.discussions.microsoft.com> wrote in message
news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values
> of the <body> tag via code-behind. I am currently setting the onload event
> in
> the body tag of an ASP.NET web form using old-fashion asp type <%..
> code...
> %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially a
> hack. And, i cannot view the HTML in DESIGN view, only CODE view. Which
> further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in the
> <body> tag, but VS.NET doesn't let me (probably for good reason too).
> Anyone have ideas?
> Thanks,
Mark <body runat=server id=_body> then manually in your codebehind add:
protected System.Web.UI.HtmlControls.HtmlGenericControl _body;
And then you should be abe to use _body.Attributes.Add() and any other API
to modify the element.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> I'm sure it's possible, but it hasn't occurred to me "how" to set the
> values of the <body> tag via code-behind. I am currently setting the
> onload event in the body tag of an ASP.NET web form using old-fashion
> asp type <%.. code... %> blocks.
> This "spaghetti-scripting" is difficult to manage, and is essentially
> a hack. And, i cannot view the HTML in DESIGN view, only CODE view.
> Which further causes problems when i try to wire events.
> I tried, for example, to embbed an <asp:label /> and other controls in
> the <body> tag, but VS.NET doesn't let me (probably for good reason
> too).
> Anyone have ideas?
> Thanks,
>
"Karl for the win!" ? hehehehe I like it! :}
Curt Christianson
Site & Scripts: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23AhK3h8LFHA.2772@.TK2MSFTNGP12.phx.gbl...
> <body id="body" runat="server">
> codebehind:
> protected body as HtmlGenericControl
> Page_Load..
> body.Attributes.Add("onLoad", "alert('Karl for the win!');")
> Karl
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "charliewest" <charliewest@.discussions.microsoft.com> wrote in message
> news:2E9D247C-4445-43A3-935D-B676C8ADE617@.microsoft.com...
> values
> in
> code...
>
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment