473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ASP.NET Reference Body element server side

115 100+
How can I reference the body element from server side code if the body does not have an id?
Jul 31 '08 #1
5 1729
Frinavale
9,735 Expert Mod 8TB
How can I reference the body element from server side code if the body does not have an id?
Why do you want to reference the body element?
Put a runat="server" in the <body> element to be able to access it from your server side code....normally you don't need to access the body element though...

-Frinny
Aug 1 '08 #2
Curtis Rutland
3,256 Expert 2GB
Why do you want to reference the body element?
Put a runat="server" in the <body> element to be able to access it from your server side code....normally you don't need to access the body element though...

-Frinny
But if it doesn't have an ID, you still can't access it.
Aug 1 '08 #3
ShadowLocke
115 100+
Why do you want to reference the body element?
Put a runat="server" in the <body> element to be able to access it from your server side code....normally you don't need to access the body element though...

-Frinny
Ive created a web control that that needs to add and event listener for onkeydown to the body. What ive done for now is during the control rendering, just wrote the javascript out to the page that will do it from there. But i think it would be a much cleaner solution if i could access the body from the web control.
Aug 1 '08 #4
Curtis Rutland
3,256 Expert 2GB
Well, give the body an id, and a runat="server" attribute.
Aug 1 '08 #5
Frinavale
9,735 Expert Mod 8TB
Ive created a web control that that needs to add and event listener for onkeydown to the body. What ive done for now is during the control rendering, just wrote the javascript out to the page that will do it from there. But i think it would be a much cleaner solution if i could access the body from the web control.
I did the same thing and went through the same thought process as you...I originally tried accessing the <body> tag to do this... but I discovered that you don't need to use the <body> tag at all. You just attach an event to the window...

eg (JavaScript code of course):

Expand|Select|Wrap|Line Numbers
  1. If(window.attachEvent){
  2.     window.attachEvent("onload","theFunctionThatIsCalledDuringOnLoad()");
  3. }else
  4. {
  5.     window.addEventListener("load","theFunctionThatIsCalledDuringOnLoad()");
  6. }
  7.  
-Frinny
Aug 1 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: feng | last post by:
I need to add an "onload" attribute to <body> tag so that I can insert client side JavaScript when the page is reloaded. It looks like I should be able to get a reference to the <body> control as...
4
by: Brian | last post by:
I am trying to use a web service from a non Microsoft product. When I do a "Add Web Reference" from the Visual Studio dialog box, a request is generated and received by the web services supplier....
5
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in...
6
by: seeIT | last post by:
In a client application a simple webservice (add/multiply) was added to solution panel but proxy methods do not appear. WSDL description in solution panel follows: <?xml version="1.0"...
5
by: Mike Logan | last post by:
I used WSDL.exe to generate a client side web proxy for a web service, called the web service, got the results but an array returned by the web service is not in the results. However if I use...
0
by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below...
3
by: rolf.oltmans | last post by:
Hello, I've been trying to access the html element "Body" in my server side code. I've searched the archives of this group and have been able to put together an example that doesn't work :)...
13
by: Dan Aldean | last post by:
Hi, I use ASP.NET 2.0 and I created a stylesheet, but I don't know how to make it visible to a web form "MyWebPage.aspx" that uses the master page. I put a reference to the css in the .master...
2
by: r_ahimsa_m | last post by:
Hello, I am learning PHP5. I need to parse XML file and I found a solution in some book on PHP5 ("PHP5 Programming" by Rasmus Lerdors and others). Unfortunately I have two problems that I don't...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.