2011年11月26日 星期六

ThickBox 用程式關閉ThickBox加一些處理

關閉跳出來的ThickBox
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove()", true);


關閉跳出來的ThickBox並重新整理
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();var win = top.window; try{ if(win){ win.location.reload(); } }catch(ex){} ;", true);


關閉跳出來的ThickBox並重新整理iframe(myiframe)
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();parent.myiframe.location.reload();", true);


關閉後點選母視窗的查詢按紐重整 s為判斷重整(看個人使用) b為button的id
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();parent.document.getElementById('" + Request.QueryString["s"].ToString() + "').value=1;parent.document.getElementById('" + Request.QueryString["b"].ToString() + "').click(); ", true);


關閉後到指定的網頁

ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();var win = top.window; try{ if(win){ win.location.href='code.aspx'; } }catch(ex){};", true);


不關閉重整父頁面(b為父頁面的查詢 s為父頁面的一個隱藏欄位用來判段是查詢還是重整用的)
<input type="button" value="Detail" style="text-align: center;" onclick="tb_show('Detail','_Statement.aspx?type=modify&id=<%# Eval("ID_Statement") %>&b=<%# this.Button2.ClientID %>&s=<%# this.HiddenFieldStatus.ClientID %>&KeepThis=true&TB_iframe=true&height=550&width=750',null);" />

ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.document.getElementById('" + Request.QueryString["s"].ToString() + "').value=1;parent.document.getElementById('" + Request.QueryString["b"].ToString() + "').click(); ", true);