简体   繁体   中英

Javascript function not being found when Button is clicked to invoke it

I have defined my OpenWin() function to handle opening the new window and pass params to it but when I compile it it says it is not defined.

>     <script type="text/javascript">
>         function OpenWin()
>             {
>                 var
> 
>                     Parms = document.getElementById('PassParmString').value;
> 
> 
>                 window.open("ViewerPane.aspx?prm=" + Parms,"_blank","left=20,top=20,width=1000,height=1140,toolbar=0,resizable=1")
>             }
>     </script>

And further down is the button script ...

>             <asp:Button ID="btnAuthenticate" OnClick="OpenWin()" runat="server" Height="44px" Style="z-index: 108;
>                 left: 716px; position: absolute; top: 243px" Text="Authenticate" Width="97px" />

Message:...

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'OpenWin' is not a member of 'ASP.default_aspx'.

Source Error:

Line 38: top: 243px" Text="UserName :"> Line 40:
Line 42:

Source File: C:\\projects\\Centauri_0.01\\ASPXRPT\\Default.aspx Line: 40

OnClick refers to server side events. Change it to OnClientClick for javascript functions.

For more information, you should read http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.onclientclick.aspx

EDIT : As far as opening of the window is concerned try changing _blank with '' like :

window.open("ViewerPane.aspx?prm=" + Parms,"","left=20,top=20,width=1000,height=1140,toolbar=0,resizable=1")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM