从c#调用Jquery [英] Calling Jquery from c#

查看:110
本文介绍了从c#调用Jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个功能



So I have this function

function lbviewmore() {
           setTimeout(function () {
               erAlert();
           }, 500);
       }





我想在一段时间后打电话给它。





I want to call it after a certain time.

void timer_Tick(object sender, EventArgs e)
   {
       alerts2 = DBExecute("exec testingt ", cs);
       int blah = alerts.Count;
       if (alerts.Count == alerts2.Count)
       {
           ClientScript.RegisterStartupScript(this.GetType(), "test", "lbviewmore()", true);
       }
       else
       {
       }
       System.Timers.Timer aTimer = new System.Timers.Timer();
       aTimer.Elapsed += new ElapsedEventHandler(timer_Tick);
       aTimer.Interval = 5000;
       aTimer.Enabled = true;
   }





如果我将clientscript放在button_click中,它就会运行。但我想在其他部分。现在只在If语句中测试它是否正常工作。任何帮助将不胜感激。



It runs if I put the clientscript within a button_click. But I want it in the else section. It is only in the If statement right now to test if it is working. Any help will be appreciated.

推荐答案

所有评论都说得好!你不能这样做。

但是你可以使用 jQuery AJAX 调用>。



阅读这篇文章:

http://www.aspsnippets.com/Articles/Call-ASPNet-Page-Method-using-jQuery-AJAX-Example.aspx [ ^ ]



-KR
All comments are well-said ! You cannot do that.
But you can make an AJAX call to server side using jQuery.

Read this article:
http://www.aspsnippets.com/Articles/Call-ASPNet-Page-Method-using-jQuery-AJAX-Example.aspx[^]

-KR


这篇关于从c#调用Jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆