Top Ad unit 728 × 90

random

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.






how to get client side multiple parameters value using single object same like object oriented way in .net. Reviewed by Vikas Kumar Singh on December 04, 2017 Rating: 5

No comments:

All Rights Reserved by DotNetBasic.com © 2019

Contact Form

Name

Email *

Message *

© 2018 All rights reserved by DotNetBasic. Powered by Blogger.