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 652773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:18:33+00:00 2026-05-13T22:18:33+00:00

I currently have this working but it requires me to have a static method

  • 0

I currently have this working but it requires me to have a static method as the method called in the code behind. I would like to be able to access some member variables that can’t be static. I’m not married to the Javascript implementation and am open to other suggestions that would help me achieve this.

If there is other information that would be helpful let me know and I can include.

EDIT: Let me clarify, I’m looking to edit a value in one of the user controls on the page based on the button click. I am holding the user controls in a list on the page and using the parameters passed through the javascript to find the user control that I want to update and modify the value there.

It currently looks like this:

Javascript:

    function incrementCompletes(obj) 
    {
        var firstParameter = $(obj).parents('.parentClass1').find('.childClass1').html();
        var secondParameter = $(obj).parents('.parentClass2').find('.childClass2').html();

        var parameters = "{'firstParam':'" + firstParameter+ "','secondParam':'" + secondParameter+ "'}";
         $.ajax({
            type: "POST",
            url: "Page.aspx/StaticMethod",
            contentType: "application/json; charset=utf-8",
            data: parameters,
            dataType: "json",
            success: 
            function DoOtherStuffHere(result) {
                var x = $(obj).parents('.classWithStuffToChange');
                var y = $(x).find('.otherClassWithStuffToChange');
                y[0].innerHTML=" + " + result.d;
            }
        });
    }

Code behind:

    [WebMethod]
    public static int StaticMethod(string parameter1, string parameter2)
    {
        //Do some stuff
        //Return a value
    }  

I would like to find a solution that does not require the method called to be static.

  • 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-13T22:18:33+00:00Added an answer on May 13, 2026 at 10:18 pm

    If you want to access member varaibles of the page, there has to be an instance of the page class. That means that you have to do a postback instead of calling a web method.

    Use a regular Button control, that will cause a postback and you can use it’s Click event to run a method in the code behind. If you don’t want the page to be reloaded, you can use ASP.NET AJAX to do the callback using AJAX.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have code that is working (posted after this) but before I expand
This was working correctly in Visual Studio 2008, but since I have switch to
I currently have this set up and working fine inside a users folder. RewriteEngine
We currently have a working php mail script, this works fine and as we
Currently, I have this version of the autocomplete control working when returning XML from
I am currently working on kerberos, and for now have this doubt on PAC
I'm currently working on wholesale online t-shirt shop. I have done this for fixed
I am currently working in this problem for hours now. I have to create
I have a working website, where I use this expression everywhere. price.ToString(C) It currently
As a beginner in Ocaml, I have this current working code: ... let ch_in

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.