从C#调用Jquery方法

本文关键字:方法 Jquery 调用 | 更新日期: 2023-09-27 18:26:43

我们需要以下功能,我们需要创建如下所示的c#方法

public string JquerySelection(string htmlString, string jQuerySelector)
{
// htmlstring:  Will have entire html of a webpage.
// jQuerySelector Will be as: $("#intro").html()
// $("#intro").html() ->    Element with Id as intro and it's html content.
// Hence element with id "intro" will be searched in htmlString and returned its value.
}

有人能建议一下,需要为此编写什么C#代码吗?

从C#调用Jquery方法

C#在服务器端运行,JQuery在客户端运行。有些库允许使用ASP.NET在服务器端执行jquery,但由于涉及大量开销,因此不鼓励使用它们。

您可以从服务器端(c#)调用javascript函数,但不确定是否使用jquery。本文对此进行了概述。

System.Web.UI命名空间中ScriptManager类的RegisterStartupScript函数将有助于实现相同的