Olena
Olena

Reputation: 303

asp:Label change visible from C# and JS code at the same time

I have asp:Label. How can I change visible from C# and js code?

Can have:

style="display: none;"

or

Visible="false"

If use first way, couldn't change visible from C# code,

if use second way, couldn't change visible from JS code.

I need have opportunity to change visible from C# and JS code at the same time. C#:

MyPanel.Visible = true;  

JS:

 $('.MyPanel').show();

Upvotes: 0

Views: 1098

Answers (1)

scartag
scartag

Reputation: 17680

You could set its style attributes using C# and then use js to change it back

MyPanel.Attributes.Add("style","display:none");

Then on the client side you can call what you declared already.

$('.Mypanel').show(); // i'm assuing you've add a class on the 'MyPanel' element.

Upvotes: 3

Related Questions