C# 如何获取控件值并在页面方法中修改它们?

C# 如何获取控件值并在页面方法中修改它们?,c#,asp.net,jquery,pagemethods,C#,Asp.net,Jquery,Pagemethods,我在页面中有两个控件。我需要在Page方法中修改这些值。我该怎么做?。当我在页面中修改这些值时,方法应该反映在页面中吗 请给我举个例子。快速示例: <asp:ScriptManager runat="server" EnablePageMethods="true" /> <!-- or ToolkitScriptManager, but remember to put only one --> <script type="text/javascript">

我在页面中有两个控件。我需要在Page方法中修改这些值。我该怎么做?。当我在页面中修改这些值时,方法应该反映在页面中吗

请给我举个例子。

快速示例:

<asp:ScriptManager runat="server" EnablePageMethods="true" />
<!-- or ToolkitScriptManager, but remember to put only one -->

<script type="text/javascript">
    function invokeMethod() {
        x = document.getElementById('<%= TextBox1.ClientID %>').value;
        PageMethods.theMethod(x, OnSuccess, OnFailure);
    }
    function OnSuccess(r) {
        document.getElementById('<%= TextBox1.ClientID %>').value = r;
    }
    function OnFailure(r) {
        alert(r._message);
    }
</script>

“页面方法”是什么意思?您的控件是.NET控件还是HTML?所谓页面方法,您指的是web服务与AJAX集成的PageMethods选项,还是什么?
    [System.Web.Services.WebMethod()]
    public static string theMethod(string x)
    {
        return x + "!!!";
    }