473,385 Members | 1,813 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,385 software developers and data experts.

Onclientclick firing twice?

<script language=javascript>
function selectFile(fileUrl)
{
if(navigator.appName.indexOf('Microsoft')!=-1)
window.returnValue=fileUrl;
else
window.opener.setAssetValue(fileUrl);
self.close();
}
</script>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
OnClientClick="selectFile('blabla')" Text="Button" />

When I run this code for some reason, it seems to do it twice. Also,
the first time I press the button the window is still open, but the
second time I press the button it correctly closes the window.

Any idea what is going on?

Also do you know the syntax of how I can pass the parameter of the text
in textbox1 instead of the 'blabla' to the javascript function?

Feb 7 '06 #1
4 3794
Generally when an event fires twices it's because an event handler is
registered twice. Maybe you have it registered both in the code behind and
the html?

"Steve" <ba****@iranmania.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
<script language=javascript>
function selectFile(fileUrl)
{
if(navigator.appName.indexOf('Microsoft')!=-1)
window.returnValue=fileUrl;
else
window.opener.setAssetValue(fileUrl);
self.close();
}
</script>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
OnClientClick="selectFile('blabla')" Text="Button" />

When I run this code for some reason, it seems to do it twice. Also,
the first time I press the button the window is still open, but the
second time I press the button it correctly closes the window.

Any idea what is going on?

Also do you know the syntax of how I can pass the parameter of the text
in textbox1 instead of the 'blabla' to the javascript function?

Feb 7 '06 #2
No, I haven't specified anything in the code behind.

Feb 7 '06 #3
Use an HTML button, not an asp.net ?

"Rick" <Ri**@nowhere.com> schreef in bericht
news:us**************@TK2MSFTNGP14.phx.gbl...
Generally when an event fires twices it's because an event handler is
registered twice. Maybe you have it registered both in the code behind and
the html?

"Steve" <ba****@iranmania.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
<script language=javascript>
function selectFile(fileUrl)
{
if(navigator.appName.indexOf('Microsoft')!=-1)
window.returnValue=fileUrl;
else
window.opener.setAssetValue(fileUrl);
self.close();
}
</script>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server"
OnClientClick="selectFile('blabla')" Text="Button" />

When I run this code for some reason, it seems to do it twice. Also,
the first time I press the button the window is still open, but the
second time I press the button it correctly closes the window.

Any idea what is going on?

Also do you know the syntax of how I can pass the parameter of the text
in textbox1 instead of the 'blabla' to the javascript function?


Feb 7 '06 #4
Since you are using C# I would double check where the designer hooks the
events.
I have seen it subscribe twice to an event due to manual deletion and
recreation of buttons.
I had the same problem a year or so ago.

HTH

SA

"Steve" <ba****@iranmania.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
No, I haven't specified anything in the code behind.

Feb 7 '06 #5

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

Similar topics

2
by: alien2_51 | last post by:
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"...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
4
by: Brian P | last post by:
I have a service that is driven by a timer that fires every 5 seconds. For the most part, it works fine. But every once in a while the timer fires twice. In the log I can see that when it fires...
0
by: Buddy Ackerman | last post by:
I want to disable a form button after it's pressed so that the user can't click it twice. So, I set the onClientClick property to "this.disabled=true;return true;". This has the effect of...
4
by: ShaneFowlkes | last post by:
I have a odd thing happening. I have a sub that is called upon a button click and it seems to be firing TWICE. I have no idea how this is happening but I suspect is has something to do with...
14
by: TS | last post by:
I have this custom data list control and i override the onItemDatabound event. After upgrading to vs 2005, this event is not always getting called, though it does at other times. No changes were...
5
by: Dan | last post by:
Hi, i try to redirect to another aspx page with jscript. I use "OnClientClick" but nothing happens. I tried two ways. What am i doing wrong? Thanks Dan ....
7
by: =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ== | last post by:
I am having trouble getting client-side events to fire on ImageButtons. Instead I am seeing postbacks. The client-side handlers end with "return false;" but they are never called. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
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...

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.