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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:53:49+00:00 2026-06-04T12:53:49+00:00

I am new to jquery ,I am apparently trying to call a c-sharp function

  • 0

I am new to jquery ,I am apparently trying to call a c-sharp function from javascript using ajax and jquery ,and I also want to pass some parameters while calling the c-sharp function ..
This is how I trying to do the same:

var _data = {

    '_mStart': document.getElementById("St_Period"),
    '_mEnd': document.getElementById("En_Period")
};

$.ajax({
    type: "POST",
    url: "maps.aspx/myFunc",
    data: _data,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
        alert("success!")
    }

});​

And here is my webmethod in aspx.cs

  [WebMethod]
    public static void myFunc(DateTime? _mStart, DateTime? _mEnd)
    {

        try
        {
            //string st = St_Period.Value.ToString();
            //string end = En_Period.Value.ToString();
            SqlConnection con=new SqlConnection("server=SWAPPS_LAP\\SQLEXPRESS;Initial Catalog=moogle;Integrated Security=True;MultipleActiveresultSets=true");
            SqlCommand cmd = new SqlCommand();
            con.Open();
            cmd = new SqlCommand("insert into MEDIA_BOOKING(ST_PERIOD,END_PERIOD,ENTERED_BY,ENTERED_ON) values(@st,@end,@by,@on)", con);
            cmd.Parameters.AddWithValue("@st", _mStart);
            cmd.Parameters.AddWithValue("@end", _mEnd);
            //cmd.Parameters.AddWithValue("@by", Session["login"].ToString());
            cmd.Parameters.AddWithValue("@on", DateTime.Now);
            cmd.ExecuteNonQuery();
            con.Close();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

When I run the code I get an error like:

Uncaught TypeError: Illegal invocation jquery.js:7601
jQuery.extend.param.add jquery.js:7601
buildParams jquery.js:7658
buildParams jquery.js:7653
buildParams jquery.js:7653
jQuery.extend.param jquery.js:7621
jQuery.extend.ajax jquery.js:7467
savebook maps.aspx:398
onclick
  • 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-06-04T12:53:50+00:00Added an answer on June 4, 2026 at 12:53 pm

    You need to pass the elements values not, the DOM elements.

    var _data = {
        '_mStart': document.getElementById("St_Period").value,
        '_mEnd': document.getElementById("En_Period").value
    };​
    

    Instead of:

    var _data = {
        '_mStart': document.getElementById("St_Period"),
        '_mEnd': document.getElementById("En_Period")
    };​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to use the new jquery-ui, and all but the resizable function
I am using the fullcalendar plugin, and want to call it from the Wordpress
The new jQuery v1.4 says this... jQuery.ajax() is now using onreadystatechange instead of a
Using jQuery UI 1.8rc3 combined with the new jquery.effects.fade.js code, I've been able to
I have application that brings response via Ajax and creates 5-20 new jQuery click
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
I'm new to jQuery. This would be no problem for me using XPath expressions,
I am new to jQuery and cannot get a selector to work using the
I am using this new jQuery plugin called jsTree www.jstree.com and using the HTML
What's the easiest way to define a new jQuery member function ? So that

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.