How to pass request to Ajax WebService

Here I am using the Asp.Net Ajax SlideShowExtender Control to create a slideshow of images that are stored in the database. This is a control that uses the GetSlides () webservice to retrieve information about the database. Now I want to pass a request to GetSlides () of the webservice so that the images rotate just like the value in the querystring. My difficulty is how to pass the request to this particular web service, I tried to use "HttpContext.Current.Request.QueryString [" id "]" but it doesn't work, why? Can anyone suggest how to pass the request to this web service.

+2


source to share


3 answers


You have to use the ContextKey function for SlideShowExtender (see its documentation ).

If your expander has been declared as a sample:

<ajaxToolkit:SlideShowExtender ID="SlideShowExtender1" runat="server" 
  TargetControlID="Image1" 
  SlideShowServiceMethod="GetSlides" 
  AutoPlay="true" 
  ImageTitleLabelID="imageTitle"
  ImageDescriptionLabelID="imageDescription"
  NextButtonID="nextButton" 
  PlayButtonText="Play" 
  StopButtonText="Stop" 
  PreviousButtonID="prevButton" 
  PlayButtonID="playButton" 
  Loop="true" />

      

And your service method GetSlides was declared with the contextKey parameter (carefully, case sensitive) like:



[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public AjaxControlToolkit.Slide[] GetSlides(string contextKey) 
{
  // Do something with contextKey here and return the slides.
}

      

Then you can pass that QueryString value to the service method with code like this in your SecondPage.aspx Page_Load.

protected void Page_Load(object sender, EventArgs e) 
{
  SlideShowExtender1.ContextKey = Request.QueryString["id"];
}

      

+3


source


To pass the request, you can do something like this

http://yourpath/service.asmx?imageid=3

      



and to access the verification from the web service you can do this

this.Context.Request.QueryString["imageid"];

      

+2


source


0


source







All Articles