我试图按下图所示激活弹出窗口,但它不起作用。请帮助使用Page.ClientScript.RegisterClientScriptBlock不起作用
public void btnSubmit_Click(Object o, EventArgs e)
{
if (checkFileExists(Convert.ToString(fileInfo)))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Msg", "<script type=\"text/javascript\" language=\"javascript\">function showMsg(){return confirm(\"This image name already exists, do you want to replace it?\");}</script>", true);
btnSubmit.OnClientClick = "return showMsg()";
}
if (something else)
{
// It does whatever is here but never pops the question above
}
}
,按钮上我有
<asp:Button class="Button" ID="btnSubmit" CausesValidation="True" Text="SUBMIT" runat="server"
OnClick="btnSubmit_Click"></asp:Button>
在我的情况下,它是行不通的,因为函数原型在我的剧本是错误的缺失'(arg,context)'来自函数签名。希望它有助于某人。 –