473,657 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add javascript at bottom of a page?

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
Nov 18 '05 #1
2 2840
Hello Brian,

If you're in VB, make sure that you have the option checked that shows you *ALL* the members in the Intellisense (something like List Advanced Members). It's on the VB property page.

--
Matt Berther
http://www.mattberther.com
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


Nov 18 '05 #2
Brian Bischof wrote:
I'm trying to add javascript to a page
Yes, this is one of those areas where .NET becomes farcical.
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.


I think the method is actually a member of the "Page" class, so your
"Me" prefix would have to be pointing to a page object for it it work.

I don't use VB so I don't know much about "Me", but here is the full VB
code example from MSDN:

LOOK OUT FOR LINE WRAP!

[Visual Basic]
<html>
<head>
<script language="VB" runat="server">
public Sub Page_Load(Sende r As Object,e As EventArgs)
' Form the script to be registered at client side.
Dim scriptString As String = "<script language=JavaSc ript>
function DoClick() {"
scriptString += "showMessage2.i nnerHTML='<h4>W elcome to
Microsoft .NET!</h4>'}"
scriptString += "function Page_Load(){ showMessage1.in nerHTML="
scriptString += "'<h4>RegisterS tartupScript Example</h4>'}<"
scriptString += "/"
scriptString += "script>"

If(Not Me.IsStartupScr iptRegistered(" Startup")) Then
Me.RegisterStar tupScript("Star tup", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10" onload="Page_Lo ad()">
<form id="myForm" runat="server">
<span id="showMessage 1"></span>
<br>
<input type="button" value="ClickMe" onclick="DoClic k()">
<br>
<span id="showMessage 2"></span>
</form>
</body>
</html>

--
Gerry Hickman (London UK)
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1886
by: clemenr | last post by:
Hi. I would like to know if the following is feasible in JavaScript. I would create a frameset where the top frame includes JavaScript. The bottom frame would be directed to the login page of an existing content management system. The javascript would then fill in the login name and password of the form, and submit the form to log in. If this works then the bottom frame would be replaced with another page requesting that a link be...
6
17166
by: Questman | last post by:
Does anyone have code they could share that would implement a telnet session in a browser using Javascript? I've seen it done once, but they did not have code available. This would be integral to preserving some old telnet-based software but allowing us to move on with web-only code at this point. Thank you in advance to anyone who can assist. (Ideally, it should be cross-browser, of course).
4
3133
by: PK9 | last post by:
I have a button at the top of my page that I have an onClick event handler for which makes some new controls (at the bottom of my page) visible. When the user clicks the button I make the new controls visible in the onclick event handler, but I do not know how to bring the focus to the bottom section of the page. So basically, when the user clicks the button, everything works correctly in the onclick (all controls are made visible),...
13
2742
by: Xah Lee | last post by:
there's this one i can't figure out. I'm trying to kick out image.google.com's top frame when it goes to my page. If you go to http://images.google.com/images?q=milk+tits click on the page http://xahlee.org/Periodic_dosage_dir/20031016_caryatids.html it should kick out the google's frame, but it isn't.
5
2194
by: Tudor Tihan | last post by:
Hi, This is my first post here, so please be kind. I have tryed to make a javascript html page loader by using an invisible <IFrame> and some javascript variable text passing between entities. This seems to brake the CSS after some depth, or perhaps I am not understanding something.
1
1766
by: JohnnieTech | last post by:
I am using some javascript/ajax to load content into a main div. The problem I am running into is that it will work in IE but not in FF. In FF I don't get any sort of load at all. I have a 1 column 2 row setup in css. The links are in the top div and the content loads in the main div. The only problem I thought may have been causing it was that I had an ID inside of and ID. I changed my links div to a class instead of an ID and that didn't...
8
6174
by: rajesh | last post by:
< script language = javascript c =...
2
3147
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button then the calender gone actually i want if i click outside off the calender then it should me removed ..How kan i do this ... Pls inform me as early as possible .. I am waiting for ur quick replay ...Here i attached the source code .... <!DOCTYPE...
19
2216
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? (in conjunction with css, you know, the usual...;) this is what is meant by "modern" javascript?? so how do folks feel about this who think javascript is so evil they disable it from their browsers?? do sites designed with "modern" javascript...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.