I am new to this kind of programming. I am trying to enable a Link Button on enter of any text in a ASP Text box. Basically it is a search text box when it has text the Search link should be enabled otherwise it should be disabled. The Search Link is a Link Button.
I have this code :- Text box:
<asp:TextBox ID="txtSearch" Width="100%" OnKeyUp='javascript:SetButtonStatus();' runat="server"></asp:TextBox>
Search Link Button:
<asp:LinkButton ID="lbtnSearch" runat="server" onclick="lbtnSearch_Click" ClientIDMode="Static">Search</asp:LinkButton>
JS Function :-
function SetButtonStatus() {
debugger;
var searchtxt = document.getElementById('<%=txtSearch.ClientID%>').value;
if (searchtxt.length >= 1) {
document.getElementById('<%=lbtnSearch.ClientID%>').disabled = "";
}
else {
document.getElementById('<%=lbtnSearch.ClientID%>').disabled = "disabled";
}
}
But this is unfortunately not working. The link button does not get enabled on entry of text in text box.
Any help is appreciated.