我在test.ascx ASP控件上有以下代码:
function mute() {
var button_mute = document.getElementById('<%= btnRequestCompanyCheck.ClientID %>');
button_mute.style.display = "none";
alert("x");
}
我怎样才能从(test.ascx.cs)后面的代码中调用Mutant(),我正在尝试以下所有列表,没有人为我工作。
我应该在Asp.net控件上使用哪一个?
ScriptManager.RegisterOnSubmitStatement(this, this.GetType(), "test", "mute()");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "test", "mute()", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "mute()", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "mute()", true);
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction","mute()", true);
最佳答案
你有尝试过吗?
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="javascript:return mute();" />
这是JavaScript代码。
<script type="text/javascript">
function mute() {
alert("Muted");
return false;
}
</script>
这是替代方法的代码
Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", "mute()", true);