I have this function from code behind (.aspx.cs):
public string GetData()
{
string str = string.Format(@"SELECT * FROM DEPT.CATERGORY WHERE CAT in ('{0}') ", HfSearch.Value);
DataTable dt = new DB().DBCat(str);
return dt == null ? "[]" : JsonConvert.SerializeObject(dt);
}
On .aspx page, I retrive the json like this in the inline script:
rowData: <%= GetData() %>,
I have move the inline script to an external js file, but this above rowData: <%= GetData() %> is no longer working. How should I code it in the external file?
Tia!
I found this link that that helped me with the answer to my question. Hope this saves others too for days of searching.
Using variables from server side code behind in functions in external JavaScript files