简体   繁体   English

点击链接按钮后需要重新加载页面

[英]Need to reload page after click on link button

Please look at 1st image. 请看第1张图片。 在此输入图像描述

In this page i use LinkButton. 在这个页面中我使用LinkBut​​ton。 ( Like... "sr001","sr003", and all ) (比如...“sr001”,“sr003”,以及所有)

.aspx page .aspx页面

<asp:LinkButton ID="lnkbtn" runat="server" onclick="lnkbtn_Click" 
ValidationGroup='<%# Eval("pid") %>'><%#Eval("productcode") %></asp:LinkButton>

.cs page .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>");
}

Now, When I clik on this link button process work successfully. 现在,当我克隆此链接按钮时,工作成功。

BUT.............. 但..............

My design is disturb by this process, look at 2nd image.. 我的设计是通过这个过程扰乱,看第二个图像..

在此输入图像描述

How can I fix this problem? 我该如何解决这个问题?

PLEASE HELP ME.... 请帮我....

Doing a raw Response.Write is not advisable since you are literally just appending content to the response stream. 不建议执行原始的Response.Write,因为您只是将内容附加到响应流。

If you want to ensure your script shows up in the proper place and executes you should use ClientScriptManager.RegisterStartupScript instead. 如果要确保脚本显示在正确的位置并执行,则应使用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);
}

Are you just wanting to reload the page once the button is clicked? 您是否只想在单击按钮后重新加载页面? If so, do a response redirect to Request.Url.AbsolutePath . 如果是, Request.Url.AbsolutePath 响应重定向Request.Url.AbsolutePath

The code: 编码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM