Overblog Follow this blog
Edit post Administration Create my blog
Balavardhan Reddy Narani

Execute particular javascript method only once, while Page onLoad only in an ASP.NET

August 5 2009 , Written by Balavardhan Reddy Published on #ASP.Net

We can execute Javascript method only once while asp.net page Loading only. We can validate the Asp.Net page IsPostBack event in Javascript method.
ASP.NET Master/Content Page scenario and have declared a javascript onload, then the script gets executed every on every postback.

However if you would like to execute it only once during the first postback, then here's how to do so:
write below code in MasterPage

<script type="text/javascript">

function invokeMeMaster() {

var chkPostBack = '<%= Page.IsPostBack ? "true" : "false" %>';

if (chkPostBack == 'false') {

alert('Only the first time');


window.onload = function() { invokeMeMaster(); };


The code determines if there is a postback in Javascript and then executes code based on the result. Hence the alert popup is shown only once.

Share this post

Repost 0

Comment on this post

a thousand years chords 04/23/2012 14:53

Hey, I just wanted to assure you that, your work is not going to waste, this piece has touched my life and inspired me to try out on this field of writing.

quotes about death of a loved one 04/14/2012 05:23

hey, gotcha. I think that the sole purpose of this article is to amaze us

adipex 04/06/2012 14:10

Thank you for the testimony! It brings me more pleasure after reading it than after taking adipex or shopping

John Mathew 02/10/2012 20:47

Interesing information. Though i couldn't get any of these information.

Idol White


Marietta bankruptcy attorney


visitor 02/10/2012 08:11

This article is well written and very informative. I really like this site because it offers loads of information to its followers.

Buy Assignment assignment writing Assignment Help Statistics Help pay someone to do your assignment Programming Assignment Help
coursework help