Pagemethods和Public共享功能? [英] Pagemethods and Public shared function?

查看:54
本文介绍了Pagemethods和Public共享功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我想使用javascript在代码隐藏中调用一个函数.到目前为止,一切都很好.请参见下面的脚本.我也有
ToolkitScriptManager EnablePageMethods ="true".在我的函数中,我需要使用标签中的值.但是,这在公共共享功能中是不可能的.实际上,我还需要从其他功能的多个标签中获取更多值.将Function更改为Public函数不起作用,因为那样我的javascript根本不会调用该函数……有人解决方案吗?

Hi All,
I wanted to call a function in codebehind using javascript. So far so good. See script below. I also have
ToolkitScriptManager EnablePageMethods="true". In my function I need to use a value from a label. However this isn''t possible in a public shared function. Actually I need to get more values from several labels for other functions as well. Changing the Function to Public function doesn''t work because then my javascript won''t call the function at all...... Anybody a solution ?

<script type="text/javascript" language="JavaScript">
window.onbeforeunload = StartCleanup;
function StartCleanup() {
PageMethods.CleanUp();
}</script>
<System.Web.Services.WebMethod()> _
Public Shared Function CleanUp() As Boolean
''when a user leaves the page or clicks cancel button we have to clean up all the stuff filled in the form like items, bioll, etc
Dim result As Boolean = bo_bill.Deletebill(somelabelinmyform.text)
Return result
End Function

推荐答案

服务器控件不可用,因为该方法不会继续进行使其可用的页面生命周期事件.您需要将任何必要的值传递给该方法.
The server controls are not available because the method doesn''t proceed through the page life cycle events that would make it avaiable. You need to pass any values necessary to the method.


您可以将参数传递给pageMethod.请参阅以下示例
you can pass parameter to the pageMethod. see the below example
function CleanUp() {
            var mperesult =


find('<% = mpeSaveChanges.ClientID %> ; '); var strSaveChanges =
find('<%= mpeSaveChanges.ClientID %>'); var strSaveChanges =


这篇关于Pagemethods和Public共享功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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