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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:07:53+00:00 2026-06-17T00:07:53+00:00

I’m building a site to build your own cake. Each cake has a base

  • 0

I’m building a site to build your own cake. Each cake has a base price, and certain options. Some options (strawberry filling for example) add an additional price to the cake. This price is in the database, found by the feature id.

I’m trying to write a function that will update the price whenever you pick some new option. To select features, I have dropdown boxes and checkboxlists. They display the text of the option, but the value of the option is the feature id. I have a JS function to go through and get the values of each selected item.

My idea is to call additionalPrice whenever a ddl/cbl is changed, which will query the database with the feature ids, and add the extra price. The problem is that PageMethods is undefined. It wont autofill when I’m typing in in VS2012, and is colored black instead of light blue. I’ve read other problems like this, and I’m pretty sure i’m doing everything right. Here’s my code…

<asp:ScriptManager ID="ScriptManager1" 
EnablePageMethods="true" 
EnablePartialRendering="true"  runat="server" />

<script>
$('.featureDropDown').change(function (a) {
            //var price = $.ajax({ url: 'ajax/totalproductprice.ashx', async: false }).responseText;
            var price = PageMethods.additionalPrice();
            alert(price);
</script>

Codebehind…

 [WebMethod] public static int additionalPrice()
    {
        return 77; 
    }

additionalPrice will have more logic once I get this to work. With this code, when you change a dropdownlist, it alerts ‘undefined’.

EDIT: Now that first question has been solved, I have another one. I am trying to set the label that holds the final price to the value returned from additionalPrice. I’m trying to do this in the onSuccess method in PageMethods. I just have a generic label at the top of the page –

<asp:Label ID="lblPrice" runat="server" />

Here is my onSuccess, and the different things I have tried. None of them do anything to the label.

function onSuccess(result) {
            alert(result + "worked");
            $('.lblPrice').attr("text", result);
            $('.lblPrice').attr('text', function () {
                $(this).attr('text', result);
            })
            $('.lblPrice').text(result);
            document.getElementById('lblPrice').value = result;
            document.all('lblPrice').innerHTML = result;
        }
  • 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-06-17T00:07:54+00:00Added an answer on June 17, 2026 at 12:07 am

    when using ASP.NET AJAX PageMethods there’s a success and failure callback function that you can subscribe to by passing two additional parameters to the call. In this case you’ll want to use

    $(function () {
        $('.featureDropDown').change(function (a) {
            //var price = $.ajax({ url: 'ajax/totalproductprice.ashx', async: false }).responseText;
            PageMethods.additionalPrice(onSuccess, onFailure);
        });
    
        function onSuccess(result) {
            alert(result);
        }
    
        function onFailure(error) {
            alert(error);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

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.