There is another way also. Suppose you have Master page as Master.master and child page as Default.aspx. Do following changes in these pages step by step.
In Design of Master page you may have a button as below.
<asp:Button ID="uxSearchButton" runat="server" Text="Search" />
Add new public property in code behind file of Master page as below.
public Button SearchButton
{
get
{
return this.uxSearchButton;
}
}
In Design part of Default.aspx add MasterType as below.
<%@ MasterType VirtualPath="~/Master.Master" %>
You may have TextBox and script in Design part of Default.aspx as below.
<asp:TextBox ID="uxSearchText" runat="server"></asp:TextBox>
<script type="text/javascript">
function changeState(uxSearchText, uxSearchButton) {
var val = document.getElementById(uxSearchText).value;
if (val.length > 0) {
document.getElementById(uxSearchButton).disabled = '';
}
else {
document.getElementById(uxSearchButton).disabled = 'disabled';
}
}
</script>
Add following lines in Page_Load event of Default.aspx page
Master.SearchButton.Attributes.Add("disabled", "disabled");
uxSearchText.Attributes.Add("onkeyup", string.Format("changeState('{0}', '{1}');", uxSearchText.ClientID, Master.SearchButton.ClientID));
Now run the page you will get the result as expected.