我试着弹出一个弹出窗口,如下所示,但它不工作。请帮帮忙
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>
发布于 2011-07-01 01:26:15
要发送给RegisterClientScriptBlock
的最后一个参数是true
,它告诉方法将脚本包装在<script>
块中,但您已经在这么做了。它可能无法工作,因为它呈现了无效的(即嵌套的)脚本标记。
https://stackoverflow.com/questions/6538640
复制相似问题