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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:33:51+00:00 2026-06-07T01:33:51+00:00

I have an expression <%= GetAddPinScript() %> that evaluates a method in my code-behind

  • 0

I have an expression <%= GetAddPinScript() %> that evaluates a method in my code-behind file. The method generates javascript which it then returns:
AddPushpin('data', 'more data', numbers, numbers, 'no');

The key here is that 'no' is a variable inserted by the code-behind method and helps the rest of my javascript determine if some content should display or not.(basically a bool)

The problem I’m having is that the method in my code-behind needs a variable(result in the below code) that is sent through an ajax call before the expression is evaluated in order to determine the correct variable to generate in the javascript — but the expression always evaluates on the page load.

So how can I prevent the expression from being evaluated before the ajax call is made?

Javascript

function displayGeneralInfo(specifics)
     {
     var callback = AddQueryString(window.location.href, "action", "displayResults");
     $.ajax({
            url: callback,
            type: "POST",
            async: false,
            data: {
                specifics: specifics
                }
                });
                <%= GetAddPinScript() %>
     }

and the AddPushpin function

function AddPushpin(name, description, latitude, longitude, selected) {
    // Add a pin to the map
    var center = new Microsoft.Maps.Location(latitude, longitude);
    var pin = new Microsoft.Maps.Pushpin(center, null);

    if(selected !== null || selected!="")
      {
      if(selected == "yes")
       {
       infoboxOptions = new Microsoft.Maps.Infobox(center,
        {                          width: 285,
                               height: 170,
                               visible:true,
                               actions:[{label: 'Associate', eventHandler: associate}]
                               });
                               map.entities.push(infoboxOptions);
        }
    }
    map.entities.push(pin);
}

and the code-behind snippet

public string GetAddPinScript()
    {
foreach (Location location in foo(x => !string.IsNullOrWhiteSpace(x.Longitude) && !string.IsNullOrWhiteSpace(x.Latitude)))
        {
            selected = "no";
            if (!result.IsNullOrEmpty())
            {
                if (location.MapPinDescription.IndexOf(result) > 0)
                    selected = "yes";
            }
            pins.Add(string.Format("AddPushpin('{0}', '{1}', {2}, {3}, '{4}');",
                location.etc1("'", @"\'"), location.etc2("'", @"\'"), location.etc3, location.etc4, selected));
           string retVal = string.Join("\n", pins.ToArray());
           return retVal;
  • 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-07T01:33:52+00:00Added an answer on June 7, 2026 at 1:33 am

    You cannot make it wait. The javascript is executed on the client and this function runs on the server. Asp.net does all the binding before it sends data to the client so there is no way you can say wait till some code runs on client and then run this function. I suggest you call this function when the ajax call is made to the server. Return some html from this function and then include this in your html in the success function.

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

Sidebar

Related Questions

My problem is that I have an expression which evaluates a given user password,
I have this expression ([^]+)|(\s\S*\s) which gets any characters that are in quotes and
I have the following code that builds an IQueryable Expression<Func<TParentEntity, TChildEntity, bool>> joinExpr =
i have regular expression which need to cover multi lines(delete comments from pascal file)
I have an expression that includes divisions, for which some of the denominators are
I have an Expression Engine plugin that has a file parameter for example: {exp:my_plugin
I have this expression in a JavaScript file... $('tbody tr:even').addClass(alt-row); It alternates the color
Is there a way to have Expression Language (EL) expressions included JavaScript files be
So far I have the expression: http://[^\.]*\.mydomain\.com/((.*?)) Which matches... http://www.mydomain.com/Images/favicon.ico But I really dont
I am running VS2010 and have Expression Blend 3 installed. I select a file,

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.