Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6133507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:14:15+00:00 2026-05-23T17:14:15+00:00

I have a VB.NET function which looks like this: <WebMethod()> _ Public Shared Function

  • 0

I have a VB.NET function which looks like this:

<WebMethod()> _
Public Shared Function AuthenticateUser(ByVal UserInfo As String, ByVal Password As String) As Boolean
    Dim UserName As String

    'Just in case
    AuthenticateUser = False

    'Extract the user name from the user info cookie string
    UserName = Globals.GetValueFromVBCookie("UserName", UserInfo)

    'Now validate the user
    If Globals.ValidateActiveDirectoryLogin("Backoffice", UserName, Password) Then
        AuthenticateUser = True
    End If

End Function

I’m trying to call it from javascript like this:

function DeleteBatchJS()
{if (confirm("Delete the ENTIRE batch and all of its contents? ALL work will be lost."))
     var authenticated = PageMethods.AuthenticateUser(get_cookie("UserInfo"), prompt("Please enter your password"))
     if (authenticated == true)
           {{var completed = PageMethods.DeleteBatchJSWM(get_cookie("UserInfo"));
            window.location = "BatchOperations.aspx";
            alert("Batch Deleted.");}}}

It calls the function, but won’t return a value. When walking through the code, my VB function does fire (it will return true so long as the correct password is typed in), but the javascript ‘authenticated’ value remains ‘undefined’. It’s like you can’t return values from VB functions to javascript.

I also tried

if PageMethods.AuthenticateUser("UserName", "Password")
   {
     //Stuff
   }

But still no luck.

What am I doing wrong?

Thanks,

Jason

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:14:16+00:00Added an answer on May 23, 2026 at 5:14 pm

    Web methods are invoked using AJAX, i.e. asynchronously, i.e. you have to wait until the method completes before consuming the results, i.e. you have to use the success callbacks:

    function DeleteBatchJS() {
        var shouldDelete = confirm('Delete the ENTIRE batch and all of its contents? ALL work will be lost.');
        if (!shouldDelete) {
            return;
        }
    
        var password = prompt('Please enter your password');
        var userInfo = get_cookie('UserInfo');
        PageMethods.AuthenticateUser(
            userInfo, 
            password,
            function(result) {
                // It's inside this callback that you have the result
                if (result) {
                    PageMethods.DeleteBatchJSWM(
                        userInfo,
                        function(data) {
                            // It's inside this callback that you know if
                            // the batch was deleted or not
                            alert('Batch Deleted.');
                            window.location.href = 'BatchOperations.aspx';
                        }
                    );
                }
            }    
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# function call which looks something like this: var res =
In an ASP.NET MVC3 application I have a function that looks like: Public Sub
I have a VB.Net function which executes a Oracle Stored Proc and returns a
Does .net have the equivilent of Delphi's QuotedStr function. This replaces all quotes with
In .net we are not allowed to have shared function/methods in abstract classes and
I have followed this tutorial which uses jQuery UI to generate Facebook tokens like:
My client-server communication looks like this: there are some so called annoucements which are
Does .NET have some type of built in function that allows filtering on Gridviews?
I have a jQuery UI Dialog working great on my ASP.NET page: jQuery(function() {
I have a syntax highlighting function in vb.net. I use regular expressions to match

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.