473,513 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

__EVENTTARGET is null or not an object

Hi

I create a new .aspx page only with a button and a span (as you can
see)...simple

When I try to click the button returns JS error (__EVENTTARGET is null
or not an object). I research about it and I found some interesting
conclusions,
some people said that this bug was fixed with the SP1 of .NET1.1
others suggests a work around technique.

on a first aproach I installed SP1 but the error persists then I try
to follow a work around technique, adding a directive to the page
(Page.RegisterHiddenField( "__EVENTTARGET", myButtonName);)
to initialize the EVENTTARGET variable but still not working.

What should I do in order to put a simple event running?

<!-- File: Example6.aspx -->
<%@ Page Language="C#" %>

<script runat="server">

protected void OnClickMyButton(object src, EventArgs e)
{
_message.InnerText = "You clicked the button!";
}

</script>
<html>
<body
<form runat="server">
<h2>ASP.NET event page</h2>
<p>
<input type="button" value="Click me!" id="mybutton" name="mybutton"
OnServerClick="OnClickMyButton" runat="server"/>

</p>
<span name="_message" id="_message" runat="server"/>

</form>
</body>
</html>
Nov 19 '05 #1
2 5764
__EVENTTARGET and __DoPostback are only rendered if an autopostback control
(one that requires javascritp to post back) is render by the page. if
asp:buttons or asp:imagebuttons are the only control rendered that submit,
the javascript postback client code is not generated (as it not needed).

-- bruce (sqlwork.com)
"Nuno" <nu***********@netcabo.pt> wrote in message
news:66**************************@posting.google.c om...
| Hi
|
| I create a new .aspx page only with a button and a span (as you can
| see)...simple
|
| When I try to click the button returns JS error (__EVENTTARGET is null
| or not an object). I research about it and I found some interesting
| conclusions,
| some people said that this bug was fixed with the SP1 of .NET1.1
| others suggests a work around technique.
|
| on a first aproach I installed SP1 but the error persists then I try
| to follow a work around technique, adding a directive to the page
| (Page.RegisterHiddenField( "__EVENTTARGET", myButtonName);)
| to initialize the EVENTTARGET variable but still not working.
|
| What should I do in order to put a simple event running?
|
|
|
| <!-- File: Example6.aspx -->
| <%@ Page Language="C#" %>
|
| <script runat="server">
|
| protected void OnClickMyButton(object src, EventArgs e)
| {
| _message.InnerText = "You clicked the button!";
| }
|
| </script>
| <html>
| <body
| <form runat="server">
| <h2>ASP.NET event page</h2>
| <p>
| <input type="button" value="Click me!" id="mybutton" name="mybutton"
| OnServerClick="OnClickMyButton" runat="server"/>
|
| </p>
| <span name="_message" id="_message" runat="server"/>
|
| </form>
| </body>
| </html>
Nov 19 '05 #2
My personal preference is to create a CodeBehind file and explicitly wire the
event delegate to my event handler. I find it easier to maintain than the
declarative method. But, this is not the problem.

The problem is in your code. Actually multiple problems:

1. No close to the <body> tag - this is the problem that fires the error

yours
<body

correct

<body>

2. No name or id for the form tag. Not a major deal with this single form
approach
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Nuno" wrote:
Hi

I create a new .aspx page only with a button and a span (as you can
see)...simple

When I try to click the button returns JS error (__EVENTTARGET is null
or not an object). I research about it and I found some interesting
conclusions,
some people said that this bug was fixed with the SP1 of .NET1.1
others suggests a work around technique.

on a first aproach I installed SP1 but the error persists then I try
to follow a work around technique, adding a directive to the page
(Page.RegisterHiddenField( "__EVENTTARGET", myButtonName);)
to initialize the EVENTTARGET variable but still not working.

What should I do in order to put a simple event running?

<!-- File: Example6.aspx -->
<%@ Page Language="C#" %>

<script runat="server">

protected void OnClickMyButton(object src, EventArgs e)
{
_message.InnerText = "You clicked the button!";
}

</script>
<html>
<body
<form runat="server">
<h2>ASP.NET event page</h2>
<p>
<input type="button" value="Click me!" id="mybutton" name="mybutton"
OnServerClick="OnClickMyButton" runat="server"/>

</p>
<span name="_message" id="_message" runat="server"/>

</form>
</body>
</html>

Nov 19 '05 #3

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

Similar topics

5
24664
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
9
21471
by: Dan | last post by:
I am trying to use Request.Form("__EVENTTARGET") to get the name of the control that caused a post back. It keeps returning "". I am not really sure why, this happens for all of my controls...
1
5149
by: RJN | last post by:
Hi In VB.Net I can know the control which fired the event using Request.Form("__EVENTTARGET"). I tried the same in C#. But it always returned null. Any other way to find out? Regards Rjn
5
5211
by: Matthew.DelVecchio | last post by:
hello, i am attempting to get my asp.net form to "remember" scroll position on post, as written in this short simple article: ...
64
3857
by: yossi.kreinin | last post by:
Hi! There is a system where 0x0 is a valid address, but 0xffffffff isn't. How can null pointers be treated by a compiler (besides the typical "solution" of still using 0x0 for "null")? -...
0
1425
by: rahuls2930 | last post by:
hi, i m using asp+c#. and i do a database call when a button is clicked using __doPostBack. the database call succeeds and after that when i refresh the page the page again makes the database...
11
3221
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
1
2127
by: Kenneth Baltrinic | last post by:
I am having a very odd problem. On a page that was working until very recently we are now encountering the following situation: The page is a very basic fill in the blank form used for changing...
9
3790
by: Francois Grieu | last post by:
When running the following code under MinGW, I get realloc(p,0) returned NULL Is that a non-conformance? TIA, Francois Grieu #include <stdio.h> #include <stdlib.h>
0
7260
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,...
0
7160
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...
0
7525
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...
0
5685
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,...
1
5086
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...
0
3233
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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 ...
0
456
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...

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.