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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:55:15+00:00 2026-05-15T00:55:15+00:00

I have some JQuery AJAX POSTing data to my backend C# WebForm. It POSTs

  • 0

I have some JQuery AJAX POSTing data to my backend C# WebForm. It POSTs to a static string WebForm method which returns a value, the JQuery uses that value to change an image url in the html. All is fine and dandy.

However, I would like to expand the functionality of the existing code (though I’m not shut out to rewriting it altogether) to allow me to manipulate the front end ASP controls from the C# backend, which I can not do due to the said static string method acting as my WebForm.

Does anyone have any ideas to help my predicament?

Backend

    [System.Web.Services.WebMethod]
    public static string ImageLoad(string address)
    {
        //if fail
        return "/Unavailable.bmp";

        //if succeed
        return "myimage.jpg";
        //third option
        else
        return "myotherimage.jpg";
    }

JQuery/AJAX

function scriptImageLoad() {
   var address = $("#txtAddress").val();
       $.ajax({
           type: "POST",
           url: "myPage.aspx/ImageLoad",
           data: "{'address':'" + address.toString() + "'}",
           contentType: "application/json; charset=utf-8",
           dataType: "text",
           success: function (output) {
                $('#imgImage').attr('src', output);
           }
       });
   }
});
  • 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-15T00:55:16+00:00Added an answer on May 15, 2026 at 12:55 am

    With the help of a colleague, I developed a different solution. A structure holds the output data I desire, it is then transfered into a string array, then returned via the static string web method. Once returned to the Jquery, the data is pushed to where it needs to go by the different indexes of the array.

    Front end

    function scriptImageLoad() {
       var address = $("#txtAddress").val();
          $.ajax({
             type: "POST",
             url: "MyForm.aspx/MyMethod",
             data: "{'address':'" + address.toString() + "'}",
             contentType: "application/json; charset=utf-8",
             dataType: "JSON",
    
             success: function (output) {
                $.each(output, function (index, value) {
                   place value in form
                   return (index != 0);
                })
                $.each(output, function (index, value) {
                   place value in form
                   return (index != 1);
                })
                $.each(output, function (index, value) {
                   place value in form
                   return (index != 2);
                })
                $.each(output, function (index, value) {
                   $('#imgImage').attr('src', this);
                   return (index != 3);
                })
             }
    

    Back end

        public struct TestStruct
        {
            public string value1;
            public string value2;
            public string value3;
            public string value4;
    
            public TestStruct(string value1, string value2, string value3, string value4)
            {
                this.value1 = value1;
                this.value2 = value2;
                this.value3 = value3;
                this.value4 = value4;
            }
        }
    
        [System.Web.Services.WebMethod]
        public static string[] MyMethod(string address)
        {
            string[] returnarray = new string[4];
            TestStruct struct;
            struct.value1 = "";
            struct.value2 = address;
            struct.value3 = "";
            struct.value4 = "/Unavailable.bmp";
    
            //if fail, return default values
                    returnstring.SetValue(struct.value1, 0);
                    returnstring.SetValue(struct.value2, 1);
                    returnstring.SetValue(struct.value3, 2);
                    returnstring.SetValue(struct.value4, 3);
                    return returnstring;
    
            //if succeed
                    struct.values = processed values;
                    set the values on returnstring
                    return returnstring;
            //else
                    struct.values = other processed values;
                    set the values on returnstring
                    return returnstring;
        }
    

    Now the only issues I have is getting the Jquery to properly display the data to the client.

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

Sidebar

Ask A Question

Stats

  • Questions 486k
  • Answers 486k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Entlib 5 does have the ability to do this. I'm… May 16, 2026 at 7:57 am
  • Editorial Team
    Editorial Team added an answer Simple Words: It tells the compiler, that there will be… May 16, 2026 at 7:57 am
  • Editorial Team
    Editorial Team added an answer You are correct. Setting a different locale will not affect… May 16, 2026 at 7:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.