我有以下 jquery 函数
> <script type="text/javascript">
>
> $(document).ready(function() {
>
> $('#callGrowel').click(function() {
> $.growlUI('Email Received', 'from Joe Bloggs');
> });
> });
>
> </script>
在我的 aspx 页面中我有一个 div
<div id="callGrowel" >Run Growe l</div>
但我需要一种从我的 C# 代码隐藏文件中调用 growlUI jquery 函数的方法,而不是单击 UI 中的 div。
这可能吗??
最佳答案
我使用了以下方式并且 100% 正常工作:
首先我创建一个函数并将我的 jquery 函数写入我的页面中的函数:
<script>
function myFunction(params) {
$.my_jquery(params...)
......
}
然后我在我的控件的事件处理程序中使用了这段代码(例如单击按钮),我的控件位于更新面板中:
protected void myButton(object sender, EventArgs e)
{
.....
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>myFunction(params...);</script>", false);
}
成功
关于c# - 从 C# 后面的 ASP.NET 代码调用 jQuery 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2397165/