0

请看第一张图片。 在此处输入图像描述

在此页面中,我使用 LinkBut​​ton。(比如……“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>");
}

现在,当我单击此链接按钮过程成功时。

但..............

我的设计被这个过程打扰了,看第二张图片..

在此处输入图像描述

我该如何解决这个问题?

请帮我....

4

2 回答 2

2

不建议执行原始 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);
}
于 2013-08-02T11:57:34.743 回答
0

Are you just wanting to reload the page once the button is clicked? If so, do a response redirect to Request.Url.AbsolutePath.

The code:

Response.Redirect(System.Web.HttpContext.Current.Request.Url.AbsolutePath);

于 2013-08-02T11:59:26.157 回答