从JavaScript调用C#函数

从JavaScript调用C#函数

问题描述:

亲爱的朋友,



我创建了一个显示数据的网页。

我在其中使用了Tab容器。

另外我需要从JavaScript调用C#函数。

但它无效。请指导我。



代码如下:

JavaScript:

Dear Friend,

I have create a web-page to display data.
I have used Tab Container in it.
Also I need to call C# function from JavaScript.
But Its not working. Kindly guide me on the same.

Code Below:
JavaScript:

function Validate()
{
//Some Code
__doPostBack('TabContainer1_TabPanel1_Button1', "OnClick");
}



C#代码:


C# Code:

protected void Button1_Click(object sender, EventArgs e)
    {
//Some Code
}

听起来你想从客户端与服务器通信。如果是这样,有办法,例如:

1. XMLHttpRequest [ ^ ]

2. 回调 [ ^ ]

3. WebService调用 [ ^ ]

4. PageMethod [ ^ ]



Pick&试试你觉得合适。
Sounds like you want to talk to server from client side. If so, there are ways to do it, like:
1. XMLHttpRequest[^]
2. Callback[^]
3. WebService call[^]
4. PageMethod[^]

Pick & Try that you find fit.


Hii。



这些链接可以帮助你实现工作......



http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/calling-an-Asp-Net-C-Sharp-method-web-method-using-javascript/ [ ^ ]



http://sappidireddy.wordpress.com/2008/03/31 / how-to-call-server-side-function-from-client-side-code-using-pagemethods-in-aspnet-ajax / [ ^ ]



http://stackoverflow.com/questions/3713/call-asp-net-function-from-javascript [ ^ ]



非常乐意提供帮助。
Hii.

these are some link that can help you to achieve your work...

http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/calling-an-Asp-Net-C-Sharp-method-web-method-using-javascript/[^]

http://sappidireddy.wordpress.com/2008/03/31/how-to-call-server-side-function-from-client-side-code-using-pagemethods-in-aspnet-ajax/[^]

http://stackoverflow.com/questions/3713/call-asp-net-function-from-javascript[^]

Thanks happy to help.