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

  • Home
  • SEARCH
  • 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 1069871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:29:04+00:00 2026-05-16T20:29:04+00:00

Im trying to send a custom HTML object from my ASP 2.0 website to

  • 0

Im trying to send a custom HTML object from my ASP 2.0 website to my webservice through jQuery ajax. But I cant get it to work.

Everything is parsed correct in my webservice when I drop the ObjectHTML part. But I get an error when I add the ObjectHTML part.

Is it possible to send custom javascript objects?

function SavePage() {
    var rowCount = $('#pageArea div.object').length;
    var i = 1;

    var objects = "[";
    $('.object').each(function(index) {
        var objectHtml = new ObjectHTML($(this).html());
        objects += "{'ObjectID': " + "'" + $(this).attr('objectid') + "', 'ObjectIndex': '" + $(this).attr('objectindex') + "', 'ObjectHTML': " + objectHtml + "}";
        if (i == rowCount)
            objects += ""
        else
            objects += ",";
        i++;
    });
    objects += "]";

    alert("{'objects': " + objects + "}");

    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: "/Folder/ObjectService.asmx/SavePage",
        data: "{'objects': " + objects + "}",
        dataType: "json",
        success:
            function(msg) {
                alert("Success!");
            },
        error:
            function(XMLHttpRequest, textStatus, errorThrown) {
                alert("Error Occured: " + errorThrown);
            }
    });
}

function ObjectHTML(rawHtml) {
    this.Html = rawHtml;
}

Webservice code:

[WebMethod(EnableSession = true)]
public string SavePage(List<PageObject> objects)
{
    return "";
}

public class PageObject
{
    private string _objectid, _objectindex;
    private ObjectHTML _objectHtml;

    public string ObjectID
    {
        get { return _objectid; }
        set { _objectid = value; }
    }

    public string ObjectIndex
    {
        get { return _objectindex; }
        set { _objectindex = value; }
    }

    public ObjectHTML ObjectHTML
    {
        get { return _objectHtml; }
        set { _objectHtml = value; }
    }
}

public class ObjectHTML
{
    private string _Html;

    public string Html
    {
        get { return _Html; }
        set { _Html = value; }
    }
}
  • 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-16T20:29:05+00:00Added an answer on May 16, 2026 at 8:29 pm

    It looks to me like you are getting a little confused between your C# classes on your server and the Javascript classes in your script.

    One thing that you could do is encode your html for JSOn by using JSON.Stringify

    var myObject = JSON.stringify({ 
        ObjectId: $(this).attr('objectid'), 
        ObjectIndex: $(this).attr('objectIndex'), 
        ObjectHtml: $(this).html()
    });
    

    This will make sure that the html is encoded as valid JSON

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

Sidebar

Related Questions

I am trying to send an email from a site I am building, but
I'm trying to send an email in Java but when I read the body
I am trying to send an anonymous object over a web service. Is there
I am trying to send some data from a LINQ query in C# to
I am trying to send more info in each message from the client (Mobile
I'm trying to send objects from bundles over a dedicated communication bundle to an
I am trying to send my dynamically created silverlight 2 page/image to a an
I'm trying to send the output to the console (or colouredconsole) ... which I'm
I'm trying to send email to Active Directory distribution groups. I know you can
i'm trying to send fake keyboard input to an application that's running in a

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.