0

how can i access div element from javascript. i am doing the code in asp.net. i want to make the div visible after clicking on a button.

the visibility code is given as follows:

i am getting an error :

BC30451: 'data1' is not declared. It may be inaccessible due to its protection level.

Javascript

var div = document.getElementById("<%=data1.ClientID %>");
div.style.visibility = 'visible';

Aspx

<div  id="data1" class="division" style="visibility: hidden">
</div>

1 Answer 1

1

Add runat=server and you can do it the way you have posted.

<div  id="data1" class="division" style="visibility: hidden" runat="server">
</div>
Sign up to request clarification or add additional context in comments.

5 Comments

Its becoming visible only for a second. how can i make visible permanently?
What are you doing with data1 in the code behind?
it contains just a section to display. and no code is written behind.
Try using display:none and display:block instead of visibility
This is a different issue, post a new question and include all of the relevant code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.