469,903 Members | 1,598 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

onclick firing twice for CheckBox and RadioButton...


Can some one tell me why the onclick is firing twice for the radion button
and checkbox controls...?

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Testing.aspx.vb"
Inherits="CustomerRelations.Testing" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Testing</title>
<!--
<script for="ckbCheckBox" event="onclick">
alert('ckbCheckBox click' +
document.getElementById("hdnActiveElementID").valu e);
//document.getElementById("hdnActiveElementID").valu e = this.id;
</script>
-->
<script language="jscript">

function doOnClickBody() {
//document.getElementById("hdnActiveElementID").valu e =
document.activeElement.id
alert(document.activeElement.offsetTop);
//alert('doOnClickBody click ' +
document.getElementById("hdnActiveElementID").valu e);
}

function doOnLoadBody() {
var selectedElementName =
document.getElementById("hdnActiveElementID").valu e;
//alert('doOnLoadBody load ' +
document.getElementById("hdnActiveElementID").valu e);
if (selectedElementName != ""){
document.getElementById(selectedElementName).focus ();
}
}
</script>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body onclick="doOnClickBody();" onload="doOnLoadBody();"
ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:CheckBox id="ckbCheckBox" style="Z-INDEX: 101; LEFT: 58px; POSITION:
absolute; TOP: 124px" runat="server" Text="Check Box"></asp:CheckBox>
<asp:RadioButton id="radRadio" style="Z-INDEX: 102; LEFT: 59px; POSITION:
absolute; TOP: 159px" runat="server" Text="Radio Button"></asp:RadioButton>
<asp:TextBox id="hdnActiveElementID" style="Z-INDEX: 103; LEFT: 48px;
POSITION: absolute; TOP: 281px" runat="server" Width="562px"></asp:TextBox>
<asp:TextBox id="hdnScrollTop" style="Z-INDEX: 104; LEFT: 48px; POSITION:
absolute; TOP: 309px" runat="server" Width="562px"></asp:TextBox>
<asp:DropDownList id="DropDownList1" runat="server" style="Z-INDEX: 105;
LEFT: 61px; POSITION: absolute; TOP: 83px" Width="201px"
AutoPostBack="True">
<asp:ListItem Value="book">book</asp:ListItem>
<asp:ListItem Value="paper">paper</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</HTML>

Nov 17 '05 #1
2 3638
Hi,

Just want to inform you that I try your code and its run as expected
(one event).

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">"

basically is 1997 or 1998.
What is all the other crap about.

==========

It fires twice ?

--------

"Visual Basic 7.0"
Each time yo pay for it, right.


"alien2_51" <dan.billow"at"n.o.s.p.a.m.monacocoach.commercialv ersion> wrote
in message news:%2******************@TK2MSFTNGP10.phx.gbl...

Can some one tell me why the onclick is firing twice for the radion button
and checkbox controls...?

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Testing.aspx.vb" Inherits="CustomerRelations.Testing" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Testing</title>
<!--
<script for="ckbCheckBox" event="onclick">
alert('ckbCheckBox click' +
document.getElementById("hdnActiveElementID").valu e);
//document.getElementById("hdnActiveElementID").valu e = this.id;
</script>
-->
<script language="jscript">

function doOnClickBody() {
//document.getElementById("hdnActiveElementID").valu e =
document.activeElement.id
alert(document.activeElement.offsetTop);
//alert('doOnClickBody click ' +
document.getElementById("hdnActiveElementID").valu e);
}

function doOnLoadBody() {
var selectedElementName =
document.getElementById("hdnActiveElementID").valu e;
//alert('doOnLoadBody load ' +
document.getElementById("hdnActiveElementID").valu e);
if (selectedElementName != ""){
document.getElementById(selectedElementName).focus ();
}
}
</script>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body onclick="doOnClickBody();" onload="doOnLoadBody();"
ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:CheckBox id="ckbCheckBox" style="Z-INDEX: 101; LEFT: 58px; POSITION: absolute; TOP: 124px" runat="server" Text="Check Box"></asp:CheckBox>
<asp:RadioButton id="radRadio" style="Z-INDEX: 102; LEFT: 59px; POSITION: absolute; TOP: 159px" runat="server" Text="Radio Button"></asp:RadioButton> <asp:TextBox id="hdnActiveElementID" style="Z-INDEX: 103; LEFT: 48px;
POSITION: absolute; TOP: 281px" runat="server" Width="562px"></asp:TextBox> <asp:TextBox id="hdnScrollTop" style="Z-INDEX: 104; LEFT: 48px; POSITION: absolute; TOP: 309px" runat="server" Width="562px"></asp:TextBox>
<asp:DropDownList id="DropDownList1" runat="server" style="Z-INDEX: 105; LEFT: 61px; POSITION: absolute; TOP: 83px" Width="201px"
AutoPostBack="True">
<asp:ListItem Value="book">book</asp:ListItem>
<asp:ListItem Value="paper">paper</asp:ListItem>
</asp:DropDownList>
</form>
</body>
</HTML>


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Shane Bishop | last post: by
4 posts views Thread by Larry Morris | last post: by
4 posts views Thread by Seraph | last post: by
4 posts views Thread by Brian P | last post: by
4 posts views Thread by ShaneFowlkes | last post: by
2 posts views Thread by ann | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.