弹出对话框,然后地址转向

liusaup 2009-05-01 09:23:41
页面上用的是updatepanel ,弹出对话框 scriptermanager.Regisster……(……)的方式来弹出对话框,可以正常弹出,但是当我 紧接着写 respond.redirect(a.aspx)的时候他直接转向了a.aspx,并没有弹出对话框,我想等惦记对话框的 确定 以后在转向,要如何 设置。
...全文
316 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuping234232783 2009-05-04
  • 打赏
  • 举报
回复
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", "alert('没有你要查找的记录')", true);
alert该成提示与连接地址就可以了
king4323210 2009-05-03
  • 打赏
  • 举报
回复
学习了
大聪 2009-05-03
  • 打赏
  • 举报
回复
你希望的事,按你现在的做法是实现不了的。

客户端与服务器端不能来回交互,楼主是C/S的程序写多了吧!

按楼上的找个方法吧。要用客户端来实现。

你还是没有搞清楚,updatepanel 的实现机制
神风凌 2009-05-03
  • 打赏
  • 举报
回复
Response.Write("<script>alert('msg');location.herf('default.aspx');</script>");
神风凌 2009-05-03
  • 打赏
  • 举报
回复
code=C#][/code]Response.Write("<script>alert('msg');location.href('default.aspx');</script>");
insus 2009-05-03
  • 打赏
  • 举报
回复
toxxj 2009-05-02
  • 打赏
  • 举报
回复

/// <summary>
/// Javascript彈出確認對話框後,並跳轉到指定的URL鏈接頁面
/// </summary>
/// <param name="message">要彈出的消息內容</param>
/// <param name="okGotoUrl">選擇確認(OK)按鈕後要跳轉到的頁面URL,站內鏈接寫相對路徑,站外鏈接需加"http://"</param>
/// <param name="cancelGotoUrl">選擇取消(Cancel)按鈕後要跳轉到的頁面URL,如果參數為Null或空字符""則返回false(不跳轉),站內鏈接寫相對路徑,站外鏈接需加"http://"</param>
/// <param name="page">當前頁面,參數可以直接寫:this 或 Page</param>
public static void ConfirmAndGotoUrl(string message, string okGotoUrl, string cancelGotoUrl, Page page)
{
string strScript = "";
if (String.IsNullOrEmpty(cancelGotoUrl))
{
strScript = "if(confirm('" + message + "')==true){window.location.href='" + okGotoUrl + "';} else {return false;}";
}
else
{
strScript = "if(confirm('" + message + "')==true){window.location.href='" + okGotoUrl + "';} else{window.location.href='" + cancelGotoUrl + "';}";
}

page.ClientScript.RegisterStartupScript(page.GetType(), null, strScript, true);
}


/// <summary>
/// Javascript彈出確認對話框後,並執行指定的Javascript腳本
/// </summary>
/// <param name="message">要彈出的消息內容</param>
/// <param name="okToScript">選擇確認(OK)按鈕後要執行的javacript腳本內容</param>
/// <param name="cancelToScript">選擇取消(Cancel)按鈕後要執行的javacript腳本內容,如果參數為Null或空字符""則返回false</param>
/// <param name="page">當前頁面,參數可以直接寫:this 或 Page</param>
public static void ConfirmAndExecuteScript(string message, string okToScript, string cancelToScript, Page page)
{

string strScript = "";
if (String.IsNullOrEmpty(cancelToScript))
{
strScript = "if(confirm('" + message + "')==true){"+okToScript+"} else{return false;}";
}
else
{
strScript = "if(confirm('" + message + "')==true){" + okToScript + "} else{" + cancelToScript + "}";
}

page.ClientScript.RegisterStartupScript(page.GetType(), null, strScript, true);

}


赤色火焰 2009-05-01
  • 打赏
  • 举报
回复
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "xukui", "<script>function myTest(){if(confirm('abcdef')){window.location='http://www.baidu.com';}else{return false;}}</script>", false);
this.Button1.Attributes.Add("onclick", "myTest()");
中年秃头大叔 2009-05-01
  • 打赏
  • 举报
回复
Response.Write("<script>alert('HI!')</script>");
Response.Write("<script>javascript:window.navigate('default.aspx');</script>");
这样一定可以,我测试过了
lovezhxf 2009-05-01
  • 打赏
  • 举报
回复
this.Response.Write("<Script>window.location = 'UserList.aspx'</Script>");
wuyq11 2009-05-01
  • 打赏
  • 举报
回复
public void AlertAndRedirect(string message, string toURL)
{
string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
HttpContext.Current.Response.Write(string.Format(js, message, toURL));
}
llsen 2009-05-01
  • 打赏
  • 举报
回复
Response.Write("<script>alert('msg');window.location.replace('default.aspx');</script>");


这样,把它写在一起

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧