Javascript 无法使用codebehind将脚本插入asp页
在我的asp.net/c页面中有一个简单的Javascript 无法使用codebehind将脚本插入asp页,javascript,asp.net,code-behind,Javascript,Asp.net,Code Behind,在我的asp.net/c页面中有一个简单的gridview控件。我想在删除我的行时显示一条消息,显示“delete successful”(删除成功)。我尝试使用该控件,但没有效果。 我的代码是 script = string.Format(@"<script type='text/javascript'>alert('Successfully deleted');</script>"); if (Page != null && !Page.ClientS
gridview
控件。我想在删除我的行时显示一条消息,显示“delete successful”(删除成功)。我尝试使用该控件,但没有效果。
我的代码是
script = string.Format(@"<script type='text/javascript'>alert('Successfully deleted');</script>");
if (Page != null && !Page.ClientScript.IsClientScriptBlockRegistered("alert"))
{
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "alert", script);
}
script=string.Format(@“警报('Successfully deleted');”;
if(Page!=null&&!Page.ClientScript.IsClientScriptBlockRegistered(“警报”))
{
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(),“警报”,脚本);
}
有谁能帮我一下吗,我是新来的….塔克斯
-Vishu请尝试以下方法:
ScriptManager.RegisterStartupScript(this.Page , typeof(Page) , Guid.NewGuid().ToString() , "alert('Successfully deleted');" , true);
希望它能起作用试试这个
代码:
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "popup();", true);
function popup() {
$("#popupdiv").fadeIn('slow');
}
其中,popup()是一个javascript函数
脚本:
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "popup();", true);
function popup() {
$("#popupdiv").fadeIn('slow');
}
popupdiv是您可以根据需求设计的div的IdJQuery没有标记,这改变了他试图做的事情。
$(“#popupdiv”).fadeIn('slow')代码>是jQuery。