在JavaScript函数中调用c#函数 [英] call c# function in JavaScript Function

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

问题描述

hiii全部
我需要从尝试过的javascript函数中调用c#函数,但发现我的javascript函数存在一些问题;

hiii all
i need to call c# function from javascript function i tried on it and i found a bit problem my javascript function was;

<pre lang="xml"><br />
function test()<br />
{<br />
''<%fillSession(); %><br />
}<br />
</pre><br />



然后将该功能提供给



and give that function to

<br />
<input id="btn_Chat" type="button" value="Start Chat" onclick="test()"  /><br />



而且我的C#函数是普通函数.

这里的问题是此功能是在页面加载中加载的,默认情况下会出现异常.我需要通过单击按钮来加载它.

有任何帮助吗????

谢谢



and my C# function is normal function.

The problem here is that this function is loaded in the page load and by default an exception appears. i need to load it in the click of the button.

Any help, please???

Thanks

推荐答案

在asp.net页面上制作网络方法或提供服务,然后调用您的方法
像:

pagemethod.methodName(parametre,onsuccessMethod,onTimeout,onerror,onabort)
Make a webmethod on your asp.net page or make a service then call your method
like:

pagemethod.methodName(parametre,onsuccessMethod,onTimeout,onerror,onabort)


您可以使用Page方法调用

请看下面的链接
http://encosia.com/using-jquery-to-direct-call -aspnet-ajax-page-methods/ [
You can use Page Method call

Please look below link
http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/[^]

Thanks
Faisal


您需要在ASP.NET上阅读一本书.一个基本的.您所有的JavaScript都在浏览器中执行.不管您的代码在哪里,服务器的内容在javascript运行之前就已结束,而js无法看到服务器上的方法.您可以阅读AJAX,但鉴于您犯了这个错误,我认为这对您来说太复杂了,并且您通常不精通.买书.
You need to read a book on ASP.NET. A basic one. All your javascript is executed in your browser. It doesn''t matter where your code is, the server stuff ends BEFORE the javascript runs, and js CANNOT see methods on the server. You can read up on AJAX, but given that you made this mistake, I''d assume that''s too complex for you, and you''re generally out of your depth. Buy a book.


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

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