473,654 Members | 3,071 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing BODY element from server side code?

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 :)
Actually, I am want to raise an event at client side and want to
perform some action on the server side when that event at client is
triggered. So here is what I am trying to do,
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt.aspx.cs" Inherits="__Def ault"%>
<html>
<head>
</head>
<body runat="server" id="mybody">

<form id="form1" action="Default .aspx" runat="server" method="post">
</form>
</html>
---
Now in my code behind file, I wrote

public partial class __Default : System.Web.UI.P age
{

void Page_Load(objec t sender, EventArgs e)
{
HtmlGenericCont rol mybody = new HTMLGenericCont rol();
mybody.Attribut es.Add("onload" ,"javascript:al ert(' hello !
');");
}
}

But nothing seems to be working , page loads and alert message doesn't
show up. What I am missing here?
Any help will be highly appreciated.

--Oltmans
P.S --I am working on ASP.NET 2.0

Oct 14 '06 #1
3 2070
<ro**********@g mail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
HtmlGenericCont rol mybody = new HTMLGenericCont rol();
Take this line out.
Oct 14 '06 #2
Hello Mark,

HtmlGenericCont rol mybody = new HTMLGenericCont rol();

Take this line out.
I took this out but it didn't work, any insight ?

Anybody else ?
--Oltmans

Oct 14 '06 #3
If all you want is just to produce an alert box when the page loads, have
you javascript code in the aspx page and pass the message from the server
side in a hidden input control:

<head>
<script>
function doOnLoad(){
if (form1.inhMessa ge.value!='')
alert (form1.inhMessa ge.value);
}
</script>
</head>
<body onload="doOnLoa d()">
<form id="form1" ...>
....
<input type="hidden" runat="server" id="inhMessage " />
</form>

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<ro**********@g mail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
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 :)
Actually, I am want to raise an event at client side and want to
perform some action on the server side when that event at client is
triggered. So here is what I am trying to do,
<%@ Page Language="C#" AutoEventWireup ="true"
CodeFile="Defau lt.aspx.cs" Inherits="__Def ault"%>
<html>
<head>
</head>
<body runat="server" id="mybody">

<form id="form1" action="Default .aspx" runat="server" method="post">
</form>
</html>
---
Now in my code behind file, I wrote

public partial class __Default : System.Web.UI.P age
{

void Page_Load(objec t sender, EventArgs e)
{
HtmlGenericCont rol mybody = new HTMLGenericCont rol();
mybody.Attribut es.Add("onload" ,"javascript:al ert(' hello !
');");
}
}

But nothing seems to be working , page loads and alert message doesn't
show up. What I am missing here?
Any help will be highly appreciated.

--Oltmans
P.S --I am working on ASP.NET 2.0

Oct 15 '06 #4

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

Similar topics

6
2303
by: J. J. Cale | last post by:
I want to access the DOM. Can something like this be done with PHP or a combination of PHP/JAVASCRIPT? not tested! <html><head><title>DOM test</title> <?php $inFileName = 'test.js'; $outFileName = 'jk.js'; function doIt() { $dd = getElementById('first'); $dd.innerText=$outFileName; }
5
14745
by: Vinod Kumar | last post by:
Hi All, Can I access a Javascript function written in an ASP.NET from the codebehind (C#) of that page? If yes, kindly give the code snippet to do this. Thanks and Regards Vinod Kumar
0
12071
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the likelihood of CRM success from less than 20 percent to 60 percent. WHITEPAPER :
37
3554
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element. However, I can't seem to access the "hover" properties. example :
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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
4150
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...
2
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.