DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 14 Aug 2007 15:24:00 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.webservices        back       

Thread Index
  1    AlBruAn .(donotspam)
          2    Laurent Bugnion, MVP


Accessing a .NET Webservice via JavaScript   
I have a need for a Web Service to retrieve values from a SQL Server database 
to populate a dropdown list.  That, without any further explanation, sounds 
quite simple.  The problem is the dropdown list is in FCKeditor, an 
open-source WYSIWYG HTML editor written entirely in JavaScript.  When the 
editor is displayed, I need to query the database based on values selected 
from two standard ASP dropdown lists on the page and return the results of 
that query to populate the dropdown list in FCKeditor.  

Should I write a section of JavaScript in my page to retrieve the selected 
indexes of the two ASP dropdown lists once a selection is made and have the 
JavaScript function call the Web Service?  If so, how do I write the Web 
Service to accept the two pieces of information?  And how, for that matter, 
do I send the message to the Web Service from JavaScript?  This thing has me 
really confused.
Date:Tue, 14 Aug 2007 15:24:00 -0700   Author:  

Re: Accessing a .NET Webservice via JavaScript   
Hi,

AlBruAn wrote:

> I have a need for a Web Service to retrieve values from a SQL Server database 
> to populate a dropdown list.  That, without any further explanation, sounds 
> quite simple.  The problem is the dropdown list is in FCKeditor, an 
> open-source WYSIWYG HTML editor written entirely in JavaScript.  When the 
> editor is displayed, I need to query the database based on values selected 
> from two standard ASP dropdown lists on the page and return the results of 
> that query to populate the dropdown list in FCKeditor.  
> 
> Should I write a section of JavaScript in my page to retrieve the selected 
> indexes of the two ASP dropdown lists once a selection is made and have the 
> JavaScript function call the Web Service?

Yes.

> If so, how do I write the Web 
> Service to accept the two pieces of information?


First, you got to decide if you really want to use a Web Service 
(meaning, SOAP) for this quite simple method. Probably it's not the best 
idea. SOAP is very bloated, and parsing a SOAP message using pure 
JavaScript is quite complex.

The best idea is probably to rather use an ASHX custom handler on the 
server, and have it send back some XML data to the calling client. This 
is rather simple, see here:
http://www.galasoft.ch/mydotnet/articles/article-2006100601.aspx



>  And how, for that matter, 
> do I send the message to the Web Service from JavaScript?  This thing has me 
> really confused.


Unfortunately I never managed to write the article's part two, which is 
how to use JavaScript to call the ASHX page you created above. 
Thankfully, it's not very complicated. You do this using the 
XmlHttpRequest object, which is available in IE, Firefox and other browsers.

To send a request using XmlHttpRequest, you should check the various 
tutorials available online.
I recommend:
http://www.ajaxtoolbox.com/

HTH,
Laurent
-- 
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Date:Fri, 17 Aug 2007 20:48:58 +0200   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us