The below code works, I’m just curious if there is a dynamic way to pass the generated
GridLeft__ctl1_GridViewLeftSearch ID into the javascript function.
pseudo code –
<HeaderTemplate>
<asp:TextBox ID="GridViewLeftTextBox" Width="80%" runat="server"
onKeyPress="javascript:SearchLeft(event);"></asp:TextBox>
<asp:Button ID="GridViewLeftSearch" runat="server" Width="100%"
OnClick="onSearchLeftGrid" Text="Search Patients" Font-Size="Small">
</asp:Button>
</HeaderTemplate>
Is their a way to access The GridViewLeftSearch Button inside this Javascript function without hard coding it?
function SearchLeft(e) {
var t = document.getElementById("GridLeft__ctl1_GridViewLeftSearch");
if (t != null) {
t.click();
}
}
try this :