It gives the following error
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
My code is
__doPostBack('<%= btnExitChatRoom.ClientID %>', '');
It gives the following error
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
My code is
__doPostBack('<%= btnExitChatRoom.ClientID %>', '');
The error does not come from that Javascript code per se. The code behind your page is trying to add or remove controls from a container that includes code blocks (<%= btnExitChatRoom.ClientID %>
in your case), and ASP.NET cannot do that.
You can work around this problem by using a data binding expression:
__doPostBack('<%# btnExitChatRoom.ClientID %>', '');
Then explicitly calling the DataBind() method of the container from your code-behind.
If you don't want to databind then take this code out of the header and put it just before the element closes