[英]Need to reload page after click on link button
請看第1張圖片。
在這個頁面中我使用LinkButton。 (比如...“sr001”,“sr003”,以及所有)
.aspx頁面
<asp:LinkButton ID="lnkbtn" runat="server" onclick="lnkbtn_Click"
ValidationGroup='<%# Eval("pid") %>'><%#Eval("productcode") %></asp:LinkButton>
.cs頁面
protected void lnkbtn_Click(object sender, EventArgs e)
{
int id;
id = Convert.ToInt32(((LinkButton)sender).ValidationGroup.ToString());
string abc = "http://development.in/prod-more-info.aspx?pid=" + id;
Response.Write("<script>window.open('" + abc.ToString() + "','_blank');</script>");
}
現在,當我克隆此鏈接按鈕時,工作成功。
但..............
我的設計是通過這個過程擾亂,看第二個圖像..
我該如何解決這個問題?
請幫我....
不建議執行原始的Response.Write,因為您只是將內容附加到響應流。
如果要確保腳本顯示在正確的位置並執行,則應使用ClientScriptManager.RegisterStartupScript
。
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsStartupScriptRegistered(this.GetType(), "MoreInfoPopup"))
{
int id;
id = Convert.ToInt32(((LinkButton)sender).ValidationGroup.ToString());
string abc = "http://development.in/prod-more-info.aspx?pid=" + id;
string script = String.Format("<script>window.open('{0}','_blank');</script>",abc);
cs.RegisterStartupScript(this.GetType(), "MoreInfoPopup", script);
}
您是否只想在單擊按鈕后重新加載頁面? 如果是, Request.Url.AbsolutePath
響應重定向到Request.Url.AbsolutePath
。
編碼:
Response.Redirect(System.Web.HttpContext.Current.Request.Url.AbsolutePath);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.