I'm trying to add javascript to a page so that it gets executed when the
page opens. I also need to do this during runtime b/c the javascript will
change each time.
In MSDN I saw that you can make the <Body> tag a server side object and then
add an attribute to it. Example:
<Body Id="Body1" runat="server">
in VB.NET
Body1.Attribute s.Add(...)
However, this doesn't work for me. When I attempt to make the <Body> tag a
server side control, this is ignored. When I look at the .aspx.vb code I see
that the Body object is never added to the code. I tried declaring it
manually but still didn't work.
I later found out in MSDN that there is a method called
RegisterStartup Script that I can call. For example
Me. RegisterStartup Script("startup ", startupscript)
But when I do Intellisense there is no such method listed. It also says
there there is a method called RegisterClientS cript, but again this doesn't
appear in my intellisense. In fact, in Help it says that there are many
"Registerxx x" methods of the Page object and my Intellisense doesn't show
any of them. So I must be missing something obvious. I tried referencing the
object "Me" as well as "Page" but neither one has these methods.
I'm running out of ideas! This sounds like it is easy according to MSDN, but
none of the methods it recommends work for my app. Please help.
Brian Bischof