The page is reloading after the PageMethod has been utilized

I am looking to implement search functionality in my popup window.

The popup includes a textbox, a button, and a grid to display the search results.

This is how the popup appears:

Upon clicking the search button, I have a JavaScript function set up to call a server-side function to populate the grid.

However, once the search button is clicked, the popup disappears.

Here is the markup for the search button:

<asp:Button ID="btnSearch" runat="server" Text="Search" 
                     OnClientClick="javascript:showGrid();return false;"></asp:Button>

JavaScript function:

function showGrid() {

        PageMethods.Search("onResult");

        return false;

    }
    function onResult() {

        return false;
    }

Server-side search function (.cs):

[WebMethod]
    public void Search()
    {
        availableMembers();
    }

However, upon checking, I noticed that the call only reaches the JavaScript function showGrid().

The Search() function on the server side is not being called, causing the popup to disappear without displaying the search results.

What could be the issue?

Please provide assistance. Thank you.

Answer №1

In my opinion, it would be beneficial to incorporate the use of Static.

[System.Web.Services.WebMethod]
    public static void Search()
    {
        availableMembers();
    }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

New to NodeJS: Utilizing Requestify to Retrieve Data from Another URL

As a newcomer in the world of NodeJs, I am faced with the task of transitioning my CodeIgniter server APIs to Node.js. Currently, I am utilizing requestify to retrieve data from a web service, and once this is accomplished, I intend to invoke an insert met ...

Cocos2D-JS is unable to import a json file that has been exported from CocosStudio

Trying to import a json file that was exported from cocosstudio v2.3.2 var myScene = ccs.sceneReader.createNodeWithSceneFile('res/Scene.json'); Found this code in the sample-cocos2d-js-scene-gui-master repository. Encountering an error: Can& ...

Creating .Net Designer modules, troubleshooting C++ and C# issues

I'm currently developing a feature-rich application geared towards designers, using Visual C++ 2.0. Even though it's based on C#, the solution should still be applicable. Here's my current setup: I have a UserControl named "Host" and anothe ...

Shuffling an array and returning it using Javascript/Angular

I have been working on implementing a shuffle/unshuffle feature in my Angular application. The concept is simple - there's a single button that, when clicked, will either shuffle an array and return the shuffled order, or if the array has already been ...

What could be causing push() to malfunction within a loop?

Here is a snippet of my code: var cdata = []; d3.text("tests.info", function(text) { var data = d3.csv.parseRows(text); data.forEach(function(d) { cdata.push({key: d[0], values: []}); }); }); The code reads a CSV file, loops through each line ...

Instructions on extracting the ID value from a specific field by utilizing a text box autocomplete feature

This is the code snippet I utilized for implementing auto complete functionality: Within the HTML View: <script> $(function () { $("#autoComp").autocomplete({ source: '@Url.Action("GetAutoComp")', ...

Generate seamless rotation within a specified time frame (+- x%)

I need to rotate a cube in my scene with a specific initial speed within a specified timeframe. The end angle of the cube must match the starting angle. To account for potential variations, I am allowing for a deviation of up to 5% in the timeframe. Cu ...

An issue arises when trying to loop using a while loop within an HTML structure

I have a small project with a predefined format, where I need to select a value from a dropdown menu and use that value to fetch data from a database and display it in HTML. While I am able to retrieve the data from the database based on the selected value ...

Is there a way to obtain two different colors from a single color?

Is there a way to use a method that displays two different colored borders in a specific color? Is it possible to implement this using PHP or jQuery? Apologies for my poor English Thank you, Rory McCrossan ...

A Comparison of Performance between If and Filter Operators in RxJS

Let's take a look at an example using RxJS. Type X: [utilizing filter] this.userService.afAuth.authState .pipe(filter(user => !!user)) .subscribe( _ => this.router.navigate(["/anything"]) ) Type Y: [utilizing if statement] this.u ...

Generating a dynamic drop-down menu in Django using database values

My goal is to create a Django app that includes dynamic drop-down lists for vehicle makes and models. When selecting a specific make, the models list should update to display only the models that fall under that make. I believe this can be achieved using j ...

Instructions for adding a Key every time a user clicks the space Key within an Input field

I built a Movie Search Page with the OMDB API. My current issue is that the API returns an error when searching for a movie with more than one word because the API URL requires a + key between each word. I am looking for a way to automatically add the + ke ...

Determine the status of a script in PHP by incorporating AJAX

I am having trouble with my file upload page in the application. I want to display "Uploading" while the file is uploading and then show "Processing" while the file is being processed. Eventually, after the script completes, my page should redirect to a sp ...

Issues with ASP.net rendering stylesheets

Here is the layout of my Index.cshtml page: <html> <head runat="server"> <link href="~/Content/index.css" rel="stylesheet" type="text/css" /> <asp:ContentPlaceHolder ID="HeadContent" runat="server" /> </head> < ...

Is there a way to prevent the "undefined" message from displaying in the console when this code is run?

Help needed! Can someone assist me in resolving the issue where the word 'undefined' is being displayed in the console? I'm a beginner in programming and struggling with this. Here's what I'm currently seeing: You are not getti ...

Guide on Implementing jQuery UI Autocomplete with Chrome's Speech Input Feature

I have recently discovered a cool feature in Chrome that allows users to dictate into any input field using speech input. Learn more here. It's easy to add this feature in Chrome: <input type="text" x-webkit-speech="x-webkit-speech" /> <!-- ...

I am facing difficulty in getting React to recognize the third-party scripts I have added to the project

I am currently working my way through the React Tutorial and have encountered a stumbling block. Below is the HTML markup I am using: <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=devi ...

Incorporate a "Back" button following the removal of the navigation bar in a Meteor-Ionic

When working on a Meteor-Angular-ionic app, I encountered a situation where I needed to hide the nav-bar in a template to create a full-screen view using the following code: <ion-view hide-nav-bar="true"> However, I then faced the challenge of addi ...

The term 'ItemIsLoading' is typically used as a type, however, it is being incorrectly used as a value in this context

Currently, I am in the process of developing a typescripted Redux store for a react project. While the Interfaces are functioning correctly, I encountered an error when attempting to pass them within the exports themselves. The error message states "' ...

Tips for troubleshooting React issue (TypeError: Cannot read property 'showModel' of null)

Learn how to set the attribute showModel and give it a value of false: Main.js import React from 'react' import 'bootstrap/dist/css/bootstrap.min.css'; import Form from 'react-bootstrap/Form' import Button from 'react-b ...