I have a javascript function for ShowDocument in which I need to call a code behind function My Js FUNCTION is as follows:
function showDocument(_id)
{
PageMethods.ShowDocument();
}
Codebehind:
[System.Web.Services.WebMethod]
public static void ShowDocument()
{
byte[] bytes;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
using (SqlCommand com = new SqlCommand("SELECT Data FROM FileUploader2", con))
{
using (SqlDataReader reader = com.ExecuteReader())
{
if (reader.Read())
{
bytes = (byte[])reader["Data"];
}
}
}
}
}
I have added EnablePageMethods= true in my aspx as well.
But when I debug, it triggers my ShowDocument function but does not go inside my code behind function. It just skips it. What am i doing wrong?