Click here to Skip to main content
14,669,324 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi everybody,
in have added an html page in asp.net website now my task is ::
i have one button and textarea in design part of html page,i want to display sqlserver table data in textarea control when clicked on button using javascript.please tell me the procedure and javascript code to do this task


thanking u very much,
sriram.
Posted
Updated 22-Jul-11 2:39am
v2
Comments
mhamad zarif 22-Jul-11 7:59am
   
what did you try ?

Rate this:
Please Sign up or sign in to vote.

Solution 1

You have to use Ajax. Create a WebMethod in code behind which actually grabs data from SQL database. Then in ScriptManager use EnablePageMethods to call that code behind method. Hope this hint help you.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

I have a database in EF5 and I am calling this data from my database using Api Controller like the following: I do have a database with data in it public class ProductsController : ApiController
{
private ProductBarCodeContext db = new ProductBarCodeContext();



//public IEnumerable<productretailer> GetRetailInfo()
//{
// return db.ProductRetailers.AsEnumerable();
//}

// GET api/Products
public dynamic GetProductDetails(string barcodeId, double longitude, double latitude)
{
//location placeholder for latitude and longtitude

var location = DbGeography.FromText(
string.Format("POINT ({0} {1})", longitude, latitude));

var distance = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettingsKeys.WithinAcceptableDistance]);

// query database table
var list = db.ProductRetailers
.Where(i => i.Product.BarcodeNumber.Equals(barcodeId))
//.Where(i => i.Retailer.Location.Distance(location) < distance)
.OrderBy(i => i.Retailer.Location.Distance(location))
.Take(5)
.ToList()
.Select(i => new
{


retailerName = i.Retailer.Name,
productName = i.Product.Name,
price = i.Price,
Distance = i.Retailer.Location.Distance(location)
});

//returns array messages by keyValuePairs


if (list == null)
{
return new
{
message = Constants.Msg[1],
};
}
else
{
return new
{
message = Constants.Msg[2],
results = list.First()
//.retailerName.ToString()

};



}

}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100