Usar função declarada no head

<< Click to Display Table of Contents >>

Navigation:  Miscelânea >

Usar função declarada no head

Previous pageReturn to chapter overviewNext page

Default.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_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></title>

    <script language='javascript'>

        function waka() {

            alert('teste de função javascript');

            return true;

        }

    </script>

</head>

<body>

  <form id="form1" runat="server">

  <div>

      <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

  </div>

  </form>

</body>

</html>

 

Default.aspx.cs

 

  protected void Button1_Click(object sender, EventArgs e)

   {

      string script = "<SCRIPT LANGUAGE='JavaScript'>waka()</SCRIPT>";

      this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ClientScript", script);

   }