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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:42:44+00:00 2026-05-21T06:42:44+00:00

I’m trying to pass form inputs into a WebMethod and doing something. I used

  • 0

I’m trying to pass form inputs into a WebMethod and doing something.
I used jQuery Serialize.

<script type="text/javascript">
        $.fn.serializeNoViewState = function () {
            return this.find("input,textarea,select,hidden")
               .not("[type=hidden][name^=__]")
               .serialize();
        }

        $(function () {
            $("#Button1").click(function (e) {
                var res = $("#myform").serializeNoViewState();
                var jsonText = JSON.stringify({ bject: res });
                $.ajax({
                    type: "POST",
                    url: "Default.aspx/Test",
                    data: jsonText,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                    //    alert("asd");


                    },
                    error: AjaxFailed
                });
            });
        });
        function AjaxFailed(result) {
            alert("Failed");
        }  
    </script>

in target WebMethod I want to Deserialize that object I passed.

[WebMethod()]
public static bool test(string bject)
{
    JavaScriptSerializer JsTool = new JavaScriptSerializer();

}

I Tried to use Javascriptserilizer Class. but I did not succeed.
now how can I use this Object?
I want to use this way for using jQuery AJAX simpler(For example passing form inputs to a WebService and inserting that in Database). Due the action I want to do is this way right ?
Welcome your Suggestions , tips .

Update:

how can I map the Serialized JS object to my C# entity object?
Is this way is good Way ? or there are better way exist ? if yes please give me some information

  • 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-21T06:42:45+00:00Added an answer on May 21, 2026 at 6:42 am

    I would recommend you working with strong types. So define a class that will contain all the necessary properties:

    public class MyModel
    {
        public string Prop1 { get; set; }
        public string Prop2 { get; set; }
    }
    

    and then have your web method take this object:

    [WebMethod()]
    public static bool test(MyModel bject)
    {
        ...
    }
    

    The name of the properties must match the input field names you are serializing in the AJAX request.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.