asp.net - JavaScript into Asp Page -


i learning javascript client side scripting language , using js in asp.. dont know when compile code, shows

compilation error:compiler error message: cs1061: 'asp.default_aspx' not contain definition 'popup' , no extension method 'popup' accepting first argument of type 'asp.default_aspx' found (are missing using directive or assembly reference?)

here code :

<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="web_test_app._default" %>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>shuraat web ki</title>     <script type ="text/javascript">     function popup()     {     alert("popup!!");     }         </script>  </head> <body>     <form id="form1" runat="server">     <div>         <asp:button id="button1" runat="server" text="button" onclick ="popup()"/>        <script type ="text/javascript">       document.write("abid");       </script>        </div>     </form> </body> </html> 

you're confusing client-side , server-side events. popup() function written in javascript , runs on client, onclick server-side event, handler runs on server , has written in language of page (c#). popup() has no meaning in context.

you can use clientclick event in order handle button click client-side. note should return false handler in order avoid postback server:

<asp:button id="button1" runat="server" text="button"     onclientclick ="popup(); return false;" /> 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -