原文:
NET使用了UpdatePanel后如何彈出對話框!
在ajax中的UpdatePanel彈出對話窗,可以使用:
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alert", "alert('更新成功!')", true);
修改后跳到另一個頁面中去時,可以使用:
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "click", "location.replace('UserManger.aspx');", true);
如果跳轉前還有提示信息的話,則可以使用:
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('更新成功!');location.replace('UserManger.aspx');", true);
?
例如:ScriptManager.RegisterStartupScript(this.UpdatePanel1,this.GetType(),?"提示",?"alert('購物車為空,請先購物!')",?true);??
?
?
protected void UpdatePanelAlert
(string
str_Message
)
??????? {
??????????? ScriptManager . RegisterStartupScript( this .UpdatePanel1, this .GetType(), " 提示 ", " alert ('" + str_Message + "')", true);
??????? }
??????? {
??????????? ScriptManager . RegisterStartupScript( this .UpdatePanel1, this .GetType(), " 提示 ", " alert ('" + str_Message + "')", true);
??????? }
?
UpdatePanelAlert
("
無此代碼
");
/////////////////////////////////////////////////////////////////////////////////////////////
asp.net ajax框架UpdatePanel彈出提示的幾種方法
2009-06-09 14:15
<asp:UpdatePanel runat="server" ID="p1">
*.cs: Microsoft.Web.UI.ScriptManager.RegisterStartupScript(p1, this.GetType(), "click", "alert('ok')", true); 在ASP.NET的UpdatePanel中不能使用Response.write("")了,感覺不是很方便。 那就用UpdatePanel支持的方法吧! this.ClientScript.RegisterClientScriptBlock(this.GetType(),"a","alert('ok!');",true); for 1.0 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('ok')", true); System.Web.UI.ScriptManager.RegisterStartupScript(Button1, this.GetType(), "click", "alert('ok')", true); ??????????? 關于updatepanel中注冊執行javascript ??? 好些天都在糊里糊涂,最近也比較懶,居然看到了個留言,永遠不更新的博客一等獎,相當尷尬,哈哈。寫一些最近自己或別人遇到的小問題吧。 ??? 1、關于updatepanel注冊js ??? 最近在項目里需要用到altas,本人也是新手,老用最簡單的updatepanel,在注冊腳本時也遇到了困難,無法注冊。本來是在 updatepanel中放了一個gridview,偶想在girdview中一個模板列點擊彈出一個窗體,注冊window.open()來解決問題。本來不是在updatepanel中,所以用ClientScript.RegisterStartupScript直接注冊挺好使。 ??? 在拖入updatepanel后發現無法注冊腳本,想想RegisterStartupScript本來是在頁面加載時啟動js的,在updatepanel中部分刷新,肯定是無法注冊的。 ??? 后來發現了ScriptManager.RegisterStartupScript方法,挺好使,呵呵。 ??? ScriptManager.RegisterClientScriptBlock(UpdatePanelName, typeof(UpdatePanel), "標識key", "腳本", true); ??? 下面是一個demo,模板列定義如下: <asp:TemplateField HeaderText="客戶ID"> ???? <ItemTemplate>??????????? ?????? <asp:LinkButton ID="linkbtnCID" runat="server" Text='<%# Eval("CID") %>' CommandName="linkbtnCID"?? >????????????????????? </asp:LinkButton> ????? </ItemTemplate> </asp:TemplateField> ?? ??? 在GridView對應的RowCommand事件中如下操作: protected void gvClientInfo_RowCommand(object sender, GridViewCommandEventArgs e) ??? { ??????? //如果是linkButton被點擊 ??????? if(e.CommandName.Equals("linkbtnCID")) ??????? { ??????????? LinkButton lbtn = (LinkButton)e.CommandSource; ??????????? GridViewRow dgRow = (GridViewRow)lbtn.Parent.Parent; ??????????? string tmpText = lbtn.Text.ToString();????????? ??????????? tmpText ="window.open('customerDetailsInfo.aspx?CID=" + tmpText + "' ,'newwindow','height=550, ??????????????? width=700, menubar=no ')"; ??????????? ScriptManager.RegisterStartupScript(this.UpdatePanel2, this.GetType(), "click", tmpText, true);????? ????? ??????? } ??? } ??? 2、關于RegisterStartupScript,RegisterClientScriptBlock ??????? RegisterStartupScript 將 js嵌入到頁面的底部,</form> 的前面 ??????? RegisterClientScriptBlock 將 js嵌入到頁面中開啟元素 <form> 后面 ??? 3、關于“該行已經屬于另一個表”錯誤 ?????? 這個問是出現在不同dataTable之間的行復制出現的問題。 ?????? 看這個代碼: ?????? DataTable tmpdt = sodo.getDataTable("text", strSql, sp);???????????? dt.Rows.Add(tmpdt.Rows[0]); ??? ???? 這個明顯的錯誤就是tmpdt的行是一個對象引用,相當于一個指針,錯誤是難免的,可有以下解決辦法: DataTable tmpdt = sodo.getDataTable("text", strSql, sp);???????????? 1、 dt.Rows.Add(tmpdt.Rows[0].ItemArray); 2、 dt.ImportRow(tmpdt.Rows[0]); |
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
