开发者

asp button onclick reloads the parent page

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜