Suppose some times you may want to run some javascript function at the start of the page, i.e when the page is completely rendered in the client side(browser) and before user starts to interact with the page. I came to face this requirement once, my scenario was I am using a gridview where paging is enabled and it contains a header checkbox in one column. If user checked a header checkbox in first page, then when user goes to second page, in the second page also that checkbox should be in selected mode. I did this by using js method.
Of course you can do easily this at server side itself, but what if the gridview that is dynamically generated and columns are not fixed it's also dynamic and u want to put the values of a checkbox header selected in to another column of gridview called selected Value.
i.e for example there are a fixed no of students in a class, each student name is shown as header along with a header checkbox and according to selected checkbox column that students marks are put into a selected column of the gridview.
Here you have to use js function easily:
At the server side you add
string chkSelectAllLowestClientID = "document.getElementById(\"" + chkSelectAllLowest.ClientID + "\")"; Page.ClientScript.RegisterStartupScript(this.GetType(), "keyExecuteAfterpageFinishesLoadingAndBeforeWindowOnloadEvent", "");
NOTE>> CheckOrUncheckLowestRates function already predefined in js file
Use Page.ClientScript.RegisterStartupScript for excecuting script after page finsihed loading in the browser.
0 comments:
Post a Comment