I have an asp.net TextBox control on my page and a search button whenever user clicks on the search button i want to validate the TextBox for Blank. i want to use a onClientClick event and pass the parameter as my Javascript function will be going to be called from external JS.
Here’s what I tried.
<asp:TextBox ID="search" runat="server">
</asp:TextBox>
<script language="javascript" type="text/javascript">
function voidsearch(s) {
alert(document.getElementById(s).value);
}
</script>
<asp:ImageButton ID="img1" runat="server" ImageUrl="Dotnetnuke.ico"
OnClientClick="voidsearch('<%= search.ClientID %>'); return false;" />
but this is throwing error. Object Required. i also passed this.search.. but same error. i dont understand why i am getting this error as i have first declared control and then called its ID.
Please anyone help me for this.
It seems that the “search” TextBox is placed onto INamingContainer, so it is ClientID property cannot be evaluated. Use the approach, described in the infragistics get clientID of dropdown in Rowedit template thread: