ASP.NET C# - Using WebMethod to run function and get return to pass back to Control
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 1 of 1

Thread: ASP.NET C# - Using WebMethod to run function and get return to pass back to Control

  1. #1
    Join Date
    Oct 2012

    ASP.NET C# - Access App_Code class WebMethod

    So i actually solved the problem below, it seems i cant access the WebMethod in app_code folder, is there any way to do it?

    Im having a problem making this work. Here is my code.

    C# Class

    public class GlobalFunctions
        public static string TextBoxCheck(string CurrentText)
            if (string.IsNullOrWhiteSpace(CurrentText))
                CurrentText = string.Empty;
                return CurrentText;
                CurrentText = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CurrentText);
                return CurrentText;
    And here is my javascript

    function CheckTextbox(textBoxID){
        var textBoxText = document.getElementById(textBoxID).value;
        PageMethods.SendForm(textBoxText, OnSucceeded, OnFailed);
    function OnSucceeded() {
        document.getElementById(textBoxID).value = CurrentText;
    function OnFailed(error) {
       // Alert user to the error.

    What happens is from my javascript, i pass the value of the textbox using the "onblur" and then after i run the WebMethod, it will return the result which i want to be passed to the textbox.

    i was using the UpdatePanel control and Scriptmanager and page method is true, what i want is to minimize the data being passed, instead of getting and requesting the data of the whole panel, i only want to get the data of the textbox after running the code.


    is it possible to run the code of the textbox in codebehind like "Textbox_TextChanged" and then retrieving the data using ajax and not update panel.
    Last edited by iAmRonald; November 17th, 2012 at 05:13 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a survey!

On-Demand Webinars (sponsored)