ASP.NET - Open new window from gridview RowCommand

Asked By Annie X on 14-Sep-10 05:42 AM
Hi, hope you can.

I'm trying to get a new window to open when i click a link in a gridview. Until now i have been using this

Response.Redirect("BulletinMsg.aspx?varBulletinID=" & e.CommandArgument, False)

but this will not open a new window.

I've tried the code below but i keep getting the following error msg

Line: 938
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '<script>'.

Protected Sub gvListBulletins_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvListBulletins.RowCommand

If e.CommandName = "lnkBtnTitle" Then


Response.Write("'BulletinAdd.aspx?varBulletinID='" & e.CommandArgument & ",'_blank')")


End If

End Sub

Any ideas how i get this to work.

Many thanks AnnieX

.net starter replied to Annie X on 14-Sep-10 05:48 AM

  try to add the attributes for linkbutton on RowDataBound of gridview.
  for eg.
in RowDataBound event of gridview

if (e.Row.RowType == DataControlRowType.DataRow)
sri sri replied to Annie X on 14-Sep-10 06:00 AM

try the below code

<asp:gridview id="grd" runat="server"....>

<a href = 'javascript:NewWindow(<%# Eval("EmployeeID")%>)'>Click Here </a>



<script language="javascript">
function NewWindow(para)
{'NewPage.aspx?eID=' + para)
Annie X replied to sri sri on 14-Sep-10 06:07 AM
Hi. Thanks you for the help that has done the trick.

All the best
sri sri replied to Annie X on 14-Sep-10 06:32 AM