Zerotoinfinity
Zerotoinfinity

Reputation: 6540

!IsPostBack event from Javascript

I am using ASP.NET

I have to set the value of a variable [testVar] into Javascript on page load. only for the first time when the page load. Just like !IsPostBack event on code side.

From next postback this function of Javascript should not call. Please let me know how to implement it.

Upvotes: 0

Views: 2458

Answers (1)

Robert Koritnik
Robert Koritnik

Reputation: 105071

Add this line to your ASPX page:

<% if (!this.IsPostBack) %>
<% { %>
    <script type="text/javascript">
    document.getElementById("<%= this.timeVar.ClientID %>").value = '1/1/2010';
    </script>
<% } %>

Upvotes: 1

Related Questions