在javascript函数直接调用C#方法 [英] Call C# method in javascript function directly

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

问题描述

如何直接调用C#方法javascript函数。 (例如:的Page_Load 的代码隐藏页方法)。请帮我。

How to call a c# method in javascript function directly. (eg page_load method of code behind page). Please help me.

推荐答案

您有多个选择,每个选择都有自己的优点和缺点。

You have multiple choices and each choice has its own pros and cons.


  • 如果你想调用Page_Load事件,只需重新加载页面: window.location.reload()和网页的加载事件将被调用。

  • 如果你想用异步做到这一点,你必须使用XMLHttpRequest(即使用一个Ajax库)。您可以使用的jQuery Ajax.Net专业或ASP .NET阿贾克斯的更新面板。

  • If you want to call page_Load event, just reload the page: window.location.reload() and the load event of your page will be called.
  • If you want to do it with Asynchronously, you have to use XMLHttpRequest (that is to use an Ajax library). You can use jQuery or Ajax.Net Professional or ASP.NET Ajax's update panel.

这篇关于在javascript函数直接调用C#方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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