I have a javascript file to add product to database and I want to call it from class in backend. Is it possible? Btw: I found nothing about this
2 Answers
You can do this with
Page.ClientScript.RegisterStartupScript(this.GetType(),"CallMyFunction","MyFunction()",true);
3 Comments
V. Aliosha
So, if I have js file sample.js, I need to replace
CallMyFunction with its path?Eugene
No, you should not. You just need to refer
sample.js on your aspx page.haddow64
@Eugene is correct (never noticed the comment from OP). Add the script file inside <script> tags on the aspx/cshtml file then it can be called with the above method from the code behind at any point.