Link to home
Start Free TrialLog in
Avatar of Abdu_Allah
Abdu_Allah

asked on

Why this simple example of ajaxToolkit:DynamicPopulateExtender does not work?!!

I just created an example of ajaxToolkit:DynamicPopulateExtender to learn it but it does not work, here is the entire code:

<form>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
 
<ajaxToolkit:DynamicPopulateExtender ID="dpe1" runat="server"
     ClearContentsDuringUpdate="true"
     TargetControlID="txtContent" ServiceMethod="HelloWorld" ServicePath="OpenTextFile.asmx.vb"     />
     
<asp:Panel ID="pnlEditor" runat="server" >
   <input type="button" onclick="$find('dpe1').populate();" ID="Button1" value="Button" />
</asp:Panel>
        <asp:Label ID="txtContent" runat="server" Text="Label"></asp:Label>
</form>
 
And ere is the service file:
 
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web.Script.Services
 
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class OpenTextFile
    Inherits System.Web.Services.WebService
 
    <WebMethod()> _
    Public Function HelloWorld() As String
       Return "Hello World"
    End Function
 
End Class

Open in new window

Avatar of carlnorrbom
carlnorrbom
Flag of Sweden image

Hi,

The service must be registered as a scriptservice in order to be consumable by script (i.e. Ajax..), please add the following line on top of your service declaration:

<System.Web.Script.Services.ScriptService()> _

/Carl.
Avatar of Abdu_Allah
Abdu_Allah

ASKER

That does not solve the problem.
Hi,

I read through the documentation, it seems the method call requires an arbitrary string parameter (contextKey) which You have not included in your method. Try changing Your method to:
Browser hick-up...

Try changing the method to:

    <WebMethod()> _
    Public Function HelloWorld(ByVal contextKey As String) As String
       Return "Hello World"
    End Function
and see if that makes a difference.

/Carl.
Sorry the problem still exist.
ASKER CERTIFIED SOLUTION
Avatar of carlnorrbom
carlnorrbom
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your code does not work for me!
By the way I opened FF's Error Console I got the following JS error: $find('dpe1') has no properties. Your code does not give any error but it does not work.
Hi,

Hmm, I do not use "$find('dpe1')" anywhere in my provided code, have You left a javascript onclick method anywhere or made any changes to the code I provided?

/Carl.
"$find('dpe1')"  is in my code that I use in the question.
I tried your code but it does not work.
Hi,

My code definately works, tried it out in IE, FF and Safari. If it's not running for You something must be misconfigured in your project / solution and/or dev. environment. You can have a look at http://norrbom.nu/movies/WorkingCode.swf.html to see an swf movie showing my code build and run on IE, FF, Safari without any problems.

/Carl.
Hi,

Did you get this working?

/Carl.
nop
Grade C just because I could'nt get this work.