c# - Calling a Javascript function from ASP.NET code-behind that is not inline JS -


i've found many examples of people calling inline js functions in html pages, i'm wondering if possible call js functions in own file.

for example if have ~/scripts/mainjs.js house of our javascript functions, there way call functions in file c# code-behind?

edit: preferably passing parameters js function

try this

string jsfunc = string.format("myfunction('{0}');", parametervalue); scriptmanager.registerstartupscript(this.page, page.gettype(), "myjsfn", jsfunc, true); 

write in aspx.cs file here myfunction function name , parametervalue argument.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -