CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    9

    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

    Code:
    public class GlobalFunctions
    {
        [WebMethod]
        public static string TextBoxCheck(string CurrentText)
        {
            if (string.IsNullOrWhiteSpace(CurrentText))
            {
                CurrentText = string.Empty;
                return CurrentText;
            }
            else
            {
                CurrentText = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(CurrentText);
                return CurrentText;
            }
        }
    }
    And here is my javascript

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

    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 06: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
  •  





Click Here to Expand Forum to Full Width

Featured