0
私のASPページからjavascript関数を呼び出そうとしますが、呼び出しは何もしません。 これは私のコードです:JavaScriptのajax関数はHTMLページasp.netから呼び出してロードしません
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="addAdmin.aspx.cs" Inherits="addAdmin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
function addAdmin() {
var auname = document.getElementById("uname")[0].value;
var apass = document.getElementById("pass")[0].value;
$.ajax({
url: "http://localhost:53236/Handler.ashx?cmd=addAdmin&auname="+ auname + "&apass=" + apass,
async: true,
dataType: "html",
success: function (response) {
$("#status").html(" <strong>One of the fields are empty..</strong> Please fill it and try again later.");
}
});
}
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1>In order to add an admin for the site, fill out the form below</h1>
<br /> <section class="status"><div id="status" ></div></section><br />
<br />
Admin Username:<input type="text" id="uname" /><br />
Admin Password:<input type="text" id="pass" /><br />
<button type="submit" onclick="javascript:addAdmin();">Submit</button><br />
</asp:Content>
ハンドラ内の機能がうまく機能している(私は手動でパラメータを送信しようとしましたが、それが正常にworkes) しかし、私はちょうど私の関数を呼び出すことはできません。
は、私のような私の関数を呼び出すために切り抜いた多くの方法を試してみました:<a href="javascript:addAdmin" >click her </a>
をし、ASP]ボタンをクリックしながら、サーバーに次のコードを使用していることを、更新パネルから呼び出す
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "addShoe()", true);
マスターページからContent1頭のタグにちょうど入っています。 問題が何であるのかわからなくて、なぜ私の機能を呼び出せないのですか