Onclientclick firing twice?

S

Steve

<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?
 
R

Rick

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?
 
E

Edwin Knoppert

Use an HTML button, not an asp.net ?

Rick said:
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?
 
M

MSDN

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top