简体   繁体   English

如何将值从javascript代码的一部分发送到ascx.cs代码文件

[英]How to send the value from javascript part of code to the ascx.cs code file

In my .ascx page there was some javascript functions.I want to send the value from this java script function to the codebehind file to execute a method. 在我的.ascx页面中有一些javascript函数。我想将此Java脚本函数中的值发送到代码隐藏文件中以执行方法。

I tried to use PageMethods but it was getting errors.As i google about this problem i found that PageMethods cannot use with .ascx control pages it can be only used with .aspx pages. 我尝试使用PageMethods,但出现了错误。当我在Google上搜索此问题时,我发现PageMethods无法与.ascx控件页一起使用,它只能与.aspx页一起使用。

Please give me some suggestion how could i perform my task.. 请给我一些建议,我该如何执行任务。

最简单的方法似乎是重构要运行到aspx页面中的功能(可以使用pagemethod)并使用javascript调用它。

Try using a webservice instead of pagemethods. 尝试使用Web服务而非页面方法。 Check out the msdn doc it has a pretty decent example. 查看msdn doc,它有一个不错的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM