Hi,
You could try hiding the controls instead of div.
Here is the code snippet you could make use of.
<script type="text/javascript">
function hideControls() {
var txtVal = document.getElementById('MainContent_txtBx').value;
var divToHide = document.getElementById('MainContent_dynamicContent');
if (txtVal == '') {
document.getElementById('MainContent_txtBx').style.display = 'none';
document.getElementById('MainContent_lbl').style.display = 'none';
}
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="hideControls()" />
<div id="dynamicContent" runat="server" style="height:50px;border-style:solid;border-color:#ff0000 #0000ff;">
<asp:Label ID="lbl" runat="server" Text="Sample message"></asp:Label>
<asp:TextBox ID="txtBx" runat="server" />
</div>
</asp:Content>
Hope this helps you a bit.
Regards,
RK