带有c#donds';行不通
带有c#donds';行不通,c#,javascript,asp.net,C#,Javascript,Asp.net,LoadClientScriptMessage函数在Response.Redirect(“SamePage.aspx”)时不工作运行良好 if (command2.ExecuteNonQuery() == 0) { LoadClientScriptMessage("Something went wrong!"); } else { LoadClientScriptMessage("It is OK!"); Response.Redirect("SamePage.as
LoadClientScriptMessage
函数在Response.Redirect(“SamePage.aspx”)时不工作代码>运行良好
if (command2.ExecuteNonQuery() == 0)
{
LoadClientScriptMessage("Something went wrong!");
}
else
{
LoadClientScriptMessage("It is OK!");
Response.Redirect("SamePage.aspx");
}
下面是LoadClientScriptMessage
的实现:
private void LoadClientScriptMessage(string message)
{
StringBuilder script = new StringBuilder();
script.Append(@"<script language='javascript'>");
script.Append(@"alert('" + message + "');");
script.Append(@"</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", script.ToString());
}
private void LoadClientScriptMessage(字符串消息)
{
StringBuilder脚本=新建StringBuilder();
script.Append(@“”);
附加(@“警报(“+”消息+“);”);
script.Append(@“”);
Page.ClientScript.RegisterStartupScript(this.GetType(),“Alert”,script.ToString());
}
您是否编写了Ajax.Utility.RegisterTypeForAjax(typeof(Sample))代码>页面加载?
和外接程序web.config
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory,Ajax"/>
</httpHandlers>
</system.web>
您是否编写了Ajax.Utility.RegisterTypeForAjax(typeof(Sample))代码>页面加载?
和外接程序web.config
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory,Ajax"/>
</httpHandlers>
</system.web>
您是否编写了Ajax.Utility.RegisterTypeForAjax(typeof(Sample))代码>页面加载?
和外接程序web.config
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory,Ajax"/>
</httpHandlers>
</system.web>
您是否编写了Ajax.Utility.RegisterTypeForAjax(typeof(Sample))代码>页面加载?
和外接程序web.config
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory,Ajax"/>
</httpHandlers>
</system.web>
响应。写入(“警报(‘警报消息’)”);
响应。写入(“警报(‘警报消息’)”);
响应。写入(“警报(‘警报消息’)”);
响应。写入(“警报(‘警报消息’)”);
当您调用Response.Redirect(“SamePage.aspx”)
时
重定向当前请求,您将看不到任何响应
为当前请求呈现
你在这里得到的只是一个新的页面。如果仍要查看警报和重定向,请删除响应。使用javascriptwindow.location.href
LoadClientScriptMessage("It is OK!");
//Response.Redirect("SamePage.aspx");
Page.ClientScript.RegisterStartupScript(this.GetType(), "redirct",
"window.location.href='somepage'",true);
当您调用Response.Redirect(“SamePage.aspx”)
时
重定向当前请求,您将看不到任何响应
为当前请求呈现
你在这里得到的只是一个新的页面。如果仍要查看警报和重定向,请删除响应。使用javascriptwindow.location.href
LoadClientScriptMessage("It is OK!");
//Response.Redirect("SamePage.aspx");
Page.ClientScript.RegisterStartupScript(this.GetType(), "redirct",
"window.location.href='somepage'",true);
当您调用Response.Redirect(“SamePage.aspx”)
时
重定向当前请求,您将看不到任何响应
为当前请求呈现
你在这里得到的只是一个新的页面。如果仍要查看警报和重定向,请删除响应。使用javascriptwindow.location.href
LoadClientScriptMessage("It is OK!");
//Response.Redirect("SamePage.aspx");
Page.ClientScript.RegisterStartupScript(this.GetType(), "redirct",
"window.location.href='somepage'",true);
当您调用Response.Redirect(“SamePage.aspx”)
时
重定向当前请求,您将看不到任何响应
为当前请求呈现
你在这里得到的只是一个新的页面。如果仍要查看警报和重定向,请删除响应。使用javascriptwindow.location.href
LoadClientScriptMessage("It is OK!");
//Response.Redirect("SamePage.aspx");
Page.ClientScript.RegisterStartupScript(this.GetType(), "redirct",
"window.location.href='somepage'",true);
您想显示警报并重定向用户,并抱怨它不起作用?还是当条件计算为true时,这是第一次调用?您想显示警报并重定向用户,并抱怨它不起作用?还是当条件计算为true时,这是第一次调用?您想显示警报并重定向用户,并抱怨它不起作用不起作用?或者它是条件求值为true时的第一个调用?您希望显示警报并重定向用户并抱怨它不起作用?或者它是条件求值为true时的第一个调用?