Click here to Skip to main content
15,999,290 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added div on button click by using javascript.
XML
<script type="text/javascript" language="javascript">

        function createDiv() {
            var divTag = document.createElement("div");

            divTag.id = "div1";

            divTag.setAttribute("align", "center");
             divTag.style.margin = "0px auto";
            divTag.className = "dynamicDiv";

            divTag.innerHTML = "This HTML Div tag created "  + "using Javascript DOM dynamically.";

            document.body.appendChild(divTag);
        }

    </script>


When i click to any other server control, its disappear. how could i remain it.
Posted
Comments
Sergey Alexandrovich Kryukov 11-Jul-12 10:56am    
You don't show how you call this method.
--SA

1 solution

There is not enough information (please see my comment to the question), but if you re-load the page by whatever reason, of course, it is loaded to its initial state, as if you did not click the button. As you are using ASP.NET, you can use session state management to store the information on the state reflecting the fact that a button was clicked before and its handler should be called in the handler of the event onload (for example).

Please see:
http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx[^],
http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900