Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

how to get client side multiple parameters value using single object same like object oriented way in .net.

Below are Client side methods using ajax post.
add any page like test.aspx and add below code.

         function ExportSetting() {
             try {
                 debugger;
                 var objRequest = {};
                 objRequest.Id = "1001";
                 objRequest.Name = "test";
                 $.ajax({
                     type: "POST",
                     url: "http://localhost:59948/WebForm1.aspx" + "/ExportData",
                     data: "{objRequest:" + JSON.stringify(objRequest) + "}",
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     success: function (data1, status) {
                         debugger;
                         var sfileName = data1.d;
                         if (emailOrExport == 'email') {
                             toastr.success("Exported report has been sent to your Email Id.");
                         }
                         else {
                         }
                     },
                     error: function (request, status, error) {
                         debugger;
                     }
                 });
             }
             catch (e) {
             }
         }
 


2). Add test.cs page and add below code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace test
{
    public partial class test: System.Web.UI.Page
    {
        public class Employee
        {
            public string _Id { get; set; }
            public string _Name { get; set; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        [WebMethod]
        public static string GetvalefromClientSidetoServerSide(Employee objRequest)
        {
            string Id = objRequest._Id;
            string Name = objRequest._Name;
            return Id + Name;
        }
    }
}



u will get all the data in objRequest in C# side.  try it and reply.








This post first appeared on Dot Net Tutorial For Beginners With Examples, please read the originial post: here

Share the post

how to get client side multiple parameters value using single object same like object oriented way in .net.

×

Subscribe to Dot Net Tutorial For Beginners With Examples

Get updates delivered right to your inbox!

Thank you for your subscription

×