hello everbody, i have a textbox on my form with a linkbutton next to it. the textbox' id is textbox1 and the linkbutton is lbSearch
in the page_load event i add:
this.TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode)
{
if ((event.which == 13) || (event.keyCode == 13))
{
document.getElementById('" + this.lbSearch.ClientID + "').click();
return false;
}
}
else
{
return true
}; ");
and in firefox this works but in internet explorer it doesn't
this is because the linkbutton get's rendered as
<a href="..."
how can i resolve this?
without changing the linkbutton to an imagebutton or regular button.
the linkbutton gets rendered like this:
<a href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$zoeken1$lbSearch", "", true, "search", "", false, true))' id="ctl00_zoeken1_lbSearch">zoek</a>
edit: i tried the following and received the following message:
function onkeydown does not always return a value
rule: 1, column: 243
source:
if(event.which || event.keyCode)
{
if ((event.which == 13) || (event.keyCode == 13))
{
var link = document.getElementById('ctl00_zoeken1_lbSearch');
__doPostBack(link.id.replace('_','$'),'');
return false;
}
else
{
return true;
}
}
else
{
return true;
};