In my web page i have a gridview which contains link to download file and link to open another web site in separate page.When i click on link gridview onRowCommand gets executed and website opens in separate window.After this when i refresh the web page, gridview onRowCommand get executed again and opens web site in separate window again which i dont want.I want that when i click on link to navigate to another web site then only it should go.I mean on page refresh, gridview onRowCommand should not get executed.
I am using Page.RegisterStartupScript to open another web site in separate window.
ASP.net 2.0
thanks
-------------------------------------------code----------------
protected void grdDisplayView_onRowCommand(object sender, GridViewCommandEventArgs e) { string path = e.CommandArgument.ToString();
if (path.Contains("http"))
{
StringBuilder sbString = new StringBuilder("<script language='javascript'>");
sbString.Append("window.open('");
sbString.Append("http://www.yahoo.com','', 'status=no,width=600,height=500,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,titlebar=yes,top=198,left=305');");
sbString.Append("</script>");
if ((!Page.ClientScript.IsStartupScriptRegistered("clientScriptExportView")))
{
Page.RegisterStartupScript("clientScriptExportView",sbString.ToString());
}
}
else
{
//download file which is locally
path = Server.MapPath(path);
System.IO.FileInfo file = new System.IO.FileInfo(path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.ContentType = "Application/octet-stream";
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.End();
}
}