I am developing an IE Addon using C#. I have javascript functions in a js file. I need to attach the js file to C# and call js functions from C#, send value to js and it must return a value.
JS File - sample.js :
function sample (str) {
//js code
}
C# File :
private void button1_Click(object sender, EventArgs e){
//Need to call sample(str) and pass 'str' value to the js function.
}
P.S : I tried the below code but getting object reference not set to instance of an object
Page page = HttpContext.Current.CurrentHandler as Page;
page.ClientScript.RegisterClientScriptInclude("sample","sample.js");
page.ClientScript.RegisterStartupScript(typeof(Page),"Test","<script type='text/javascript'>sample('str');</script>");