Calling Javascript from a Class Library

前端 未结 2 364
感动是毒
感动是毒 2021-01-22 11:31

I have created a class library DLL to be referenced from any third-party application and it contains only one function that calls a JavaScript to read a local file and returns s

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-22 12:08

    You can get the page instance from within the HttpContext like this:

    Page page = (Page)(HttpContext.Current.Handler);
    page.ClientScript.RegisterClientScriptBlock(...);
    

    This is C# but should be easy to convert to VB.NET as well.

    Edit: here is the VB syntax:

    Dim page As Page = HttpContext.Current.Handler
    page.ClientScript.RegisterClientScriptBlock(...)
    

提交回复
热议问题