2
Answers

How to call c# method from javascript function

User007

User007

7y
731
1
In my application I need to call aspx.cs method from javascript function call.
 
 I tried this one in
 
  <img id='img2' width="9px" border="0" src="plus.gif" onclick="MyHeader()"/> Header <div>
<asp:GridView ID="GrdHeader" runat="server" AutoGenerateColumns="false">
<Columns>
</Columns>
</asp:GridView></div>
 
My Javascript Function:
 
function MyHeader() {
PageMethods.BindHeaderGrid();
}
 
My code behined method:
 
[WebMethod]
public void BindHeaderGrid()
{
GrdHeader.DataSource = ds.Tables[0];
GrdHeader.DataBind();
}
 
But it is not call this function. 
 
 
Answers (2)