R
Rob Roberts
Is there any way to prevent a ButtonField in a GridView from doing a
postback when clicked? I want to use my own onclick handler to call
window.open('SomePage.aspx') to display a page in a new browser window when
the button is clicked.
I tried doing this in the RowCommand postback event by doing this in the
event handler:
Response.Write("<script>window.open('SomePage.aspx');</script>");
This works, but has an undesirable side effect: It adds the page to the
history list every time one of the button fields is clicked. So for example
if the user clicked three button fields to show three popup windows, and
then wants to return back to the previous page, he must click the Back
button four times instead of just once.
I'm using the RowDataBound event to add my own onclick event handler to the
button's attribute collection, but I can't figure out how to get rid of the
"javascript:__doPostBack(...)" that asp.net automatically adds. I tried
using button.Attributes.Remove("onclick") before adding my own onclick event
handler, but the "javascript:__doPostBack(...)" ends up still being there.
Any ideas on how to stop the postback?
Thanks in advance,
--Rob Roberts
postback when clicked? I want to use my own onclick handler to call
window.open('SomePage.aspx') to display a page in a new browser window when
the button is clicked.
I tried doing this in the RowCommand postback event by doing this in the
event handler:
Response.Write("<script>window.open('SomePage.aspx');</script>");
This works, but has an undesirable side effect: It adds the page to the
history list every time one of the button fields is clicked. So for example
if the user clicked three button fields to show three popup windows, and
then wants to return back to the previous page, he must click the Back
button four times instead of just once.
I'm using the RowDataBound event to add my own onclick event handler to the
button's attribute collection, but I can't figure out how to get rid of the
"javascript:__doPostBack(...)" that asp.net automatically adds. I tried
using button.Attributes.Remove("onclick") before adding my own onclick event
handler, but the "javascript:__doPostBack(...)" ends up still being there.
Any ideas on how to stop the postback?
Thanks in advance,
--Rob Roberts