开发者

asp button onclick reloads the parent page

开发者 https://www.devze.com 2023-04-11 17:28 出处:网络
I have a button and added onlcik event from the code behind. When I click on the button it reloads the parent page. What could be the problem? Please let me know.

I have a button and added onlcik event from the code behind. When I click on the button it reloads the parent page. What could be the problem? Please let me know.

<asp:Button ID="btnReport" runat="server" Text="Report"/>

Code behind:

string url = "http://www.google.com";

Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWin", 
    "<script language=javascript>function Report() { window.open ('" + 
    url + "', null,'top=1,left=1,center=yes,resizable=no,Width=840px,
    Height= 300px,status=no,titlebar=no;toolbar=no,
    menubar=no,location=no,scrollbars=yes')开发者_如何学编程;}</script>");

btnReport.Attributes.Add("OnClick", "Report()");


I think you should actually use the OnClientClick attribute:

btnReport.Attributes.Add("OnClientClick", "Report()");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号