I have a page with method to insert a javascript into a page.
public void ControleEtiquetaDermaClub(bool visualiza)
{
if (visualiza == true)
{
String jscript = "";
jscript = " $(document).ready(function() { ";
jscript += " document.getElementById('mostra-detalhe-derma').style.display = 'block'; ";
jscript += " }); ";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", jscript, true);
}
else
{
String jscript = "";
jscript = " $(document).ready(function() { ";
jscript += " document.getElementById('mostra-detalhe-derma').style.display = 'none'; ";
jscript += " }); ";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyScript", jscript, true);
}
}
After the loaded page I have the code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scripttype="text/javascript">
//<![CDATA[
$(document).ready(function() {
document.getElementById('mostra-detalhe-derma').style.display = 'block';
}); //]]>
</script>
You are inserting in the page Master, in the page of the content I have:
<div id="mostra-detalhe-derma" style="display:none">
<!--adicionar desconto derma club 24-05-2017 página Tabela.ascx-->
<a href="/loginloreal.aspx">
<img id="derma-detalhe" class="img-responsive" alt="derma club" src="../../img/DetalheProduto/dermaclub-vitrine.png"/>
</a>
</div>
You're not switching div style