Link to home
Start Free TrialLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

On post back the value entered to an element using javascript is gone

I have asp:button, whoch on click calls a javascript function to assign the date to a html (p) element. I can see the datetime for a second, but I think on postback the value of the element is gone. How do I make sure after the user clicks on the button the datetime value is still shown. I have attached the code thnaks
<html xmlns="" >
    <script type="text/javascript">
        function displayDate() {
            document.getElementById("demo").innerHTML = Date();
    <form id="form1" runat="server">
<h1>My First Web Page</h1>

<p id="demo"></p>
<asp:Button ID="btn" Text="disp" runat="server" OnClientClick="return displayDate();" />

Open in new window

Avatar of BurnieP
Flag of Canada image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TrialUser


oh perfect thx