M
mhylden
I need to make an imagebutton that is contained in a datagrid respond
only to a mouse click, and not a return key press. I have a user
control on the same page that contains text boxes (HTML controls) and
link buttons (.NET web controls) to handle the return key press as a
search. That part works, but when I do that, I still get a js
confirmation that goes along with the link buttons in the datagrid, as
if one of those had been clicked. Clicking cancel on the confirm
dialog lets the response.redirect command from the search linkbutton
continue on to the search results as expected, but I don't want the
confirm to come up at all. I'd like to take the return key action off
of the image buttons entirely, since the user should pick a specific
row from the grid. I can't just disable the imagebutton though, since
a click still needs to work.
I've tried fiddling with the tab indexes on the different controls to
get it to fire one and not the other, but no luck.
Any help is greatly appreciated.
Mikkel
Code snippets below:
this is the script for the imagebutton confirm, located at the top of
my ASPX page that contains the datagrid:
<script language="javascript">
function ConfirmQuickComplete()
{
return confirm('Are you sure you want to mark
this action item as
complete?');
}
</script>
script that checks for the return key press and fires redirect to
search, located at the top of my user control:
function CheckEnter()
{
var e = window.event;
var key = e.keyCode;
var src = e.srcElement;
var srcName = src.id;
if (key == 13)
{
if (srcName == 'txtFindProjHTML')
{
alert(srcName + key);
__doPostBack('QuickPicks1$lbFindProj','');
return false;
}
}
}
LinkButton click event handler, in user control:
private void lbFindProj_Click(object sender, System.EventArgs e)
{
string stxt = Request["txtFindProjHTML"];
Response.Redirect(Request.ApplicationPath +
"/ActionTrack/ProjectList.aspx?projName=" + stxt,true);
}
The imagebutton is a template column in my datagrid, and I set
properties on that in the ItemDataBound event on the grid as follows:
....
ImageButton btn = (ImageButton)(e.Item.Cells[6].Controls[1]);
btn.Attributes.Add("onclick", "return
ConfirmQuickComplete();");
btn.Attributes.Add("TabIndex", "0");
....
only to a mouse click, and not a return key press. I have a user
control on the same page that contains text boxes (HTML controls) and
link buttons (.NET web controls) to handle the return key press as a
search. That part works, but when I do that, I still get a js
confirmation that goes along with the link buttons in the datagrid, as
if one of those had been clicked. Clicking cancel on the confirm
dialog lets the response.redirect command from the search linkbutton
continue on to the search results as expected, but I don't want the
confirm to come up at all. I'd like to take the return key action off
of the image buttons entirely, since the user should pick a specific
row from the grid. I can't just disable the imagebutton though, since
a click still needs to work.
I've tried fiddling with the tab indexes on the different controls to
get it to fire one and not the other, but no luck.
Any help is greatly appreciated.
Mikkel
Code snippets below:
this is the script for the imagebutton confirm, located at the top of
my ASPX page that contains the datagrid:
<script language="javascript">
function ConfirmQuickComplete()
{
return confirm('Are you sure you want to mark
this action item as
complete?');
}
</script>
script that checks for the return key press and fires redirect to
search, located at the top of my user control:
function CheckEnter()
{
var e = window.event;
var key = e.keyCode;
var src = e.srcElement;
var srcName = src.id;
if (key == 13)
{
if (srcName == 'txtFindProjHTML')
{
alert(srcName + key);
__doPostBack('QuickPicks1$lbFindProj','');
return false;
}
}
}
LinkButton click event handler, in user control:
private void lbFindProj_Click(object sender, System.EventArgs e)
{
string stxt = Request["txtFindProjHTML"];
Response.Redirect(Request.ApplicationPath +
"/ActionTrack/ProjectList.aspx?projName=" + stxt,true);
}
The imagebutton is a template column in my datagrid, and I set
properties on that in the ItemDataBound event on the grid as follows:
....
ImageButton btn = (ImageButton)(e.Item.Cells[6].Controls[1]);
btn.Attributes.Add("onclick", "return
ConfirmQuickComplete();");
btn.Attributes.Add("TabIndex", "0");
....