I have the following code to set the text of the button through javascript code , but it does not work it remains same the text remains same.
function showFilterItem() {
if (filterstatus == 0) {
filterstatus = 1;
$find('<%=FileAdminRadGrid.ClientID %>').get_masterTableView().showFilterItem();
document.getElementById("ShowButton").innerHTML = "Hide Filter";
}
else {
filterstatus = 0;
$find('<%=FileAdminRadGrid.ClientID %>').get_masterTableView().hideFilterItem();
document.getElementById("ShowButton").innerHTML = "Show filter";
}
}
And my html button code is
<input class="button black" id="ShowButton" type="button" runat="server" value="Show Filter" onclick="showFilterItem()" />
If the
HTMLElementisinput[type='button'],input[type='submit'], etc.change it using this code:
If, the
HTMLElementisbutton[type='button'],button[type='submit'], etc:change it using any of these methods,
Please note that
inputis an empty tag and cannot haveinnerHTML,innerTextortextContentbuttonis a container tag and can haveinnerHTML,innerTextortextContentIgnore this answer if you ain’t using asp.net-web-forms, asp.net-ajax and rad-grid
You must use
valueinstead of.innerHTMLTry this.
And since you are running the button at
serverthe ID may get mangled in the framework. I so, tryAnother better way to do this is like this.
On markup, change your onclick attribute like this.
onclick="showFilterItem(this)"Now use it like this