Solved

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

Posted on 2008-10-18
14
3,115 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:Abdu_Allah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22748976
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.
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22749298
That does not solve the problem.
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22749421
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:
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22749426
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.
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22749497
Sorry the problem still exist.
0
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
ID: 22751785
Hi,

Please review the attached snippet, this code works just fine for me. If You still can't get it working, I suggest maybe watching the HDI video by Joe Stagner on the DynamicPopulate extender for some tips on how to implement it.

http://www.asp.net/learn/ajax-videos/video-91.aspx

/Carl.
AutoPopulat.aspx:
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AutoPopulate.aspx.vb" Inherits="AutoPopulate" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Dynamic Populate Test Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="~/WebService.asmx" />
        </Services>
    </asp:ScriptManager>
    <div>
        <asp:TextBox ID="TextBox1" runat="server" Width="275px"></asp:TextBox><br /><br />
        <input type="button" id="btnPopulate" value="Populate" />
        <cc1:DynamicPopulateExtender ID="dp1" 
                                     runat="server" 
                                     ClearContentsDuringUpdate="true" 
                                     ServicePath="WebService.asmx" 
                                     ServiceMethod="AutoPopulate" 
                                     TargetControlID="TextBox1" 
                                     PopulateTriggerControlID="btnPopulate" >
        </cc1:DynamicPopulateExtender>
    </div>
    </form>
</body>
</html>
 
WebService.vb:
 
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
 
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
    Inherits System.Web.Services.WebService
 
    <WebMethod()> _
    Public Function AutoPopulate(ByVal contextKey As String) As String
        Return "Message from service at: " & DateTime.Now.ToString
    End Function
 
End Class

Open in new window

0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22752272
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.
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22752324
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.
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22752501
"$find('dpe1')"  is in my code that I use in the question.
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22752503
I tried your code but it does not work.
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22753105
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.
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 22774063
Hi,

Did you get this working?

/Carl.
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22774863
nop
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 22790548
Grade C just because I could'nt get this work.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question