0

I use asp.net webform. But I am confused that how to send data between project?

This is project structure in sam solution

  • UI
  • BSClass(Business Class)

I used google to search for this solution but I didn't find.

Is it possible to send data by jQuery.post() from UI to Bussiness class? and How?

example Send Username and Password From UI to UserClass in BSClass

Thank you very much _/\_

2 Answers 2

0

Have a look at the articles referenced in the answer to this question:

Using jQuery for ajax with asp.net webforms

0

You won't be able to post directly to Business Class. I am assuming here that your business class is somewhere in middle and not the very first layer interacting with customer.

What you need to do is expose some method of your code behind as:

 [WebMethod]
 public static void UpdateName(string firstName, string lastName)
 {
   //do something here
 }

You need to decorate this method with [WebMethod] attribute and keep it static as well.

And then call this method from jQuery either via jQuery.ajax or jQuery.post method. Following is one snippet how you can use jQuery.ajax:

var dataString = "{'firstName':'" + firstName + "','lastName':'" + lastName + "'}";

jQuery.ajax({
   type: "POST",
   url: "Default.aspx/" + operation,
   contentType: "application/json; charset=utf-8",
   data: dataString,
   dataType: "json",
});

Exposing code behind methods as [WebMethod] is quick and dirty way. In a long term you should figure out and develop your web services with Ajax in scope and directly call web services for any data retrieval or update.

HTH

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.