从C#后面的ASP.NET代码调用jQuery函数

我有以下jquery函数

>  > > $(document).ready(function() { > > $('#callGrowel').click(function() { > $.growlUI('Email Received', 'from Joe Bloggs'); > }); > }); > >  

在我的aspx页面中,我有一个div

 
Run Growe l

但我需要一种从C#中的代码隐藏文件调用growlUI jquery函数的方法,而不是单击UI中的div。

这可能吗??

这真的没有意义。 您的C#代码在服务器上运行以生成HTML文件,该文件将传递到客户端并在那里进行转换。 jQuery只能在客户端的HTML上运行。

是你试图通过替换来实现的

  $('#callGrowel').click(function() { $.growlUI('Email Received', 'from Joe Bloggs'); }); 

  $.growlUI('Email Received', 'from Joe Bloggs'); 

我使用以下方式,并为我100%正确地工作:

第一个我创建一个函数并将我的jquery函数写入我的页面中的函数:

  

然后我在我的控件的事件处理程序中使用此代码(例如,单击一个按钮)我的控件在更新面板中:

 protected void myButton(object sender, EventArgs e) { ..... ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "", false); } 

成功