Click here to Skip to main content
15,069,297 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to call a javascript function of external file on onload or onsorted events of gridview in asp.net
Posted

   
Comments
thatraja 7-Nov-11 11:50am
   
5!
You may follow below steps for this.

1) Add a reference of your External JavaScript file in your Aspx Page.
HTML
<script type="text/javascript" src="Scripts/MyJavascript.js"></script>

2) Use Load or/and Sorting Evetnts of your GridView to call your JavaScript function.

http://msdn.microsoft.com/en-us/library/system.web.ui.control.load.aspx

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.sorting.aspx

3) Call JavaScript function as below.
C#
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "GridLoad", "<script type="text/javascript">Test()</script>");
   
Comments
thatraja 7-Nov-11 11:50am
   
5!
All you need is some customization(by your own), here some examples for you.

Using JavaScript with ASP.Net GridView Control[^]
GridView Examples in ASP.NET 2.0 3.5[^]
GridView Examples[^]
   

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