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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:28:09+00:00 2026-05-28T02:28:09+00:00

I know we already have many posts about this topic, but I just cannot

  • 0

I know we already have many posts about this topic, but I just cannot figure out how to pass the data to WebMethod! All I need is to pass one string data to my WebMethod, but do I need to use list data type?

.js

function buttonClicked () {
$.ajax({
    type: "POST",
    dataType: "json",
    contentType: "application/json",
    url: "Chat.aspx/send",
    data: "{'text':'" + $("#writeBox").val() +  "'}",
    success: function () {
    },
    error: function () {
    }
});
}

.aspx (updated with full codes)// I commented out the part that incurs error

[System.Web.Services.WebMethod]
void send (string text) {
    string id = HttpContext.Current.Request.Cookies["id"].ToString();
    string queryString = "INSERT INTO Log (ID, Text, Date) Values (" + id + ", " + text + ", GETDATE())";
    System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection("Data Source=.\\SQLExpress;Initial Catalog=ChatV1;Integrated Security=True");
    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(queryString, con);
    using (con)
    {
       con.Open();
       //cmd.ExecuteNonQuery();
    }
}
  • 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-28T02:28:09+00:00Added an answer on May 28, 2026 at 2:28 am
    [System.Web.Services.WebMethod]
    public static void send (string text) {
        string id = HttpContext.Current.Request.Cookies["id"].ToString();
        string queryString = "INSERT INTO Log (ID, Text, Date) Values (" + id + ", " + text + ", GETDATE())";
        System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection("Data Source=.\\SQLExpress;Initial Catalog=ChatV1;Integrated Security=True");
        System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(queryString, con);        
           con.Open();
           cmd.ExecuteNonQuery();
           con.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read many posts about this now but I do not still understand
I've read several of the posts on stack overflow already about this topic, but
I know this kind of questions have been asked already many times before. The
I have a feeling that I already know the answer to this one, but
I already looked up many posts about this problem (subqueries being very slow in
I know this has been addressed many times, but i just cant seem to
As many of you may already know I have been having issues with another
OK, I know there have already been questions about getting started with TDD ..
There are already quite some posts about the Singleton-Pattern around, but I would like
I know I have already answered a similar question ( Running Batch File in

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.