I am learning javascript client-side scripting language and I use js in ASP .. I don’t know when I compile the code, it shows
COMPILATION ERROR: Compiler Error Message: CS1061: 'ASP.default_aspx' does not contain a definition for 'popup' and the extension method 'popup' takes the first argument, the type 'ASP.default_aspx' can be found (do you miss the using directive or the assembly reference?)
here is my 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>
. popup() Javascript , OnClick , (#). popup() .
popup()
ClientClick, click . , , , false , :
false
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick ="popup(); return false;" />
popup() OnClientClick Click :
OnClientClick
Click
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick ="popup()"/>
, OnClick #/VB.Net(Code-Behind) (, , ), , OnClientClick Javascript.
OnClick
OnClick - server side click handler . If you want to call javascript function use OnClientClick.
Source: https://habr.com/ru/post/1791806/More articles:How to split a variable between classes in Java, I tried static did not work - java"SetupOpenInfFile" gets an access violation error in Delphi2010 - delphiwhy run the method is not called? - javaAccess to iterator object in debugger - pythonНужна помощь в анализе html в python3, недостаточно хорошо сформирована для xml.etree.ElementTree - pythonClose Google SketchUp File - ruby | fooobar.comUsing Ruby to close windows on Mac OS X - ruby | fooobar.comRuby Stones on Google-Sketchup - rubygemsSelecting multiple rows from one row in SQL - c #Загрузка сообщения и setTimeout - javascriptAll Articles