如何调用从cs文件的JavaScript / jQuery的功能(C#)功能、文件、cs、jQuery

2023-09-03 01:14:17 作者:玖爺、

我正在asp.net(C#)项目,其中包括一些网页文件(ASPX,aspx.cs)有的只(的.cs)文件。我能够使用网页文件(ASPX,aspx.cs) scriptregister 访问的JavaScript / jQuery的功能,但我的问题是如何从单独访问的JavaScript / jQuery函数(的.cs)文件。我产生一些HTML标签(的.cs)需要从只(的.cs)类调用JavaScript / jQuery的功能,因此文件。

I'm working on asp.net (C#) project which include some page files (aspx, aspx.cs) and some only (.cs) file. I'm able to access JavaScript/jQuery functions from page files (aspx, aspx.cs) using scriptregister, but my question is how to access the JavaScript/jQuery function from alone (.cs) file. I'm generating some html tags in (.cs) file therefore in need of to call JavaScript/jQuery functions from only (.cs) class.

文件我有,例如, Default.aspx的 Default.aspx.cs 和 Web.cs (我关心的是调用从web.cs的JavaScript / jQuery的功能)

The file I have are, for example, Default.aspx and Default.aspx.cs and Web.cs (My concern is to call JavaScript/jQuery functions from web.cs)

其实,我试图做的是要产生一些HTML code在Web.cs(业务对象),并同时在web.cs生成HTML code我需要一些其他的动态HTML code。通过jQuery的功能,输出生成的是我所关心的:无功输出=我的HTML code。通过jQuery函数生成的

Actually, What I'm trying to do is to generate some HTML code in Web.cs (Business Object) and while generating HTML code in web.cs I need some other dynamic HTML code generated by jQuery function which output is my concern: var output ="My HTML Code Generated by jQuery function"

现在我需要上面的jQuery输出的合并与Web.cs HTML code发生。

Now I need the above jQuery output to merger with Web.cs HTML code generating.

请让我知道它怎么可能从web.cs调用jQuery的功能和取回从jQuery的结果,以web.cs以合并?

Kindly let me know how can it be possible to call jQuery functions from web.cs and get back the result from jQuery to web.cs in order to merge?

感谢

推荐答案

您可以尝试写一个直接响应流和输出

you can try to write to a response stream directly and output

Response.Write("<script type=\"text/javascript\"> your JS call</script>");

问候, Szymon

Regards, Szymon