Popupcontrol extender with user control

Last post 07-07-2008 10:37 PM by Zhi-Qiang Ni - MSFT. 5 replies.

Sort Posts:

  • Popupcontrol extender with user control

    06-12-2008, 10:06 AM
    • Member
      point Member
    • subbarayan
    • Member since 05-27-2008, 12:58 PM
    • Posts 3

     Hi,

    I have used popup control extender (Ajax tool kit 1.0) in user control.  I want to get the data using the popup control extender from database.

    I have used the same process in aspx page its working perfectly.  But, User control can shows  an error. 

    Error rendering control - update panel.

    An unhandled exception has occured

    The control with ID 'Poppuexe' requires a scriptManager on the page.

     

    The codes in ascx

     <%@ Control Language="VB" AutoEventWireup="false" CodeFile="UserControl.ascx.vb"
        Inherits="Controls_UserControl" %>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Label ID="LinkButton1" runat="server" Text="Click"></asp:Label>
            <ajaxToolkit:PopupControlExtender ID="PoppuExe" runat="server" DynamicContextKey='<%# Eval("PropertyId")  %>'
                DynamicServiceMethod="callfun" TargetControlID="LinkButton1" DynamicControlID="Panel1"
                PopupControlID="Panel1" Position="Bottom">
            </ajaxToolkit:PopupControlExtender>
            <asp:Panel ID="Panel1" runat="server" Width="250px">
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>

    ascx.vb 

     Imports AjaxControlToolkit
    'Imports AgentFacade
    Imports System
    Imports System.Data
    Imports System.Collections
    Imports System.Data.SqlClient
    Imports HSSPMS.BusinessFacade
    Imports System.IO

    Partial Class Controls_UserControl
        Inherits System.Web.UI.UserControl

        Shared dtContactLst As New DataSet
        Shared objCustMstr As New CustomerFacade

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            Dim PropertyId As String = "TN8564565"

            Dim pce6 As PopupControlExtender = TryCast(Me.FindControl("PoppuExe"), PopupControlExtender)

            ' Set the BehaviorID6
            Dim behaviorID6 As String = String.Concat("pce6", 0)
            pce6.BehaviorID = behaviorID6
            Dim OnMouseOverScript6 As String = String.Format("$find('{0}').showPopup();", behaviorID6)
            Dim OnMouseOutScript6 As String = String.Format("$find('{0}').hidePopup();", behaviorID6)

            LinkButton1.Attributes.Add("onmouseover", OnMouseOverScript6)
            LinkButton1.Attributes.Add("onmouseout", OnMouseOutScript6)
            'LinkButton1.Text = "CheckUS"

        End Sub

        Public Shared Function ContactList(ByVal dsContact As DataSet)
            Dim strTemp As New StringBuilder()

            If dsContact.Tables(0).Rows.Count > 0 Then
                strTemp.Append("<table>")
                strTemp.Append("<tr><td><b>Contact Info:</b></td></tr>")
                Dim dr As DataRow
                For Each dr In dsContact.Tables(0).Rows
                    strTemp.Append("<tr><td>E-Mail :  " & dr.Item(1).ToString() & "</td></tr>")
                    strTemp.Append("<tr><td>Tel No : " & dr.Item(2).ToString() & "</td></tr>")
                    strTemp.Append("<tr><td>Fax No: " & dr.Item(3).ToString() & "</td></tr>")
                Next
                strTemp.Append("</table>")
            Else
                strTemp.Append("<table>")
                strTemp.Append("<tr><td><b>My Contact Info.</b></td></tr>")
                strTemp.Append("</table>")
            End If

            Return strTemp.ToString()

        End Function

        <System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()> _
      Public Shared Function callfun(ByVal contextKey As String) As String

            dtContactLst = objCustMstr.GetLandlordReviewContactListInfo("LL564547", "TN8564565")
            Return ContactList(dtContactLst)

        End Function
    End Class

     

    Any one can help me.

    subbiee.

     

     

     

     

     

  • Re: Popupcontrol extender with user control

    06-12-2008, 10:11 AM
    • All-Star
      28,218 point All-Star
    • johram
    • Member since 06-13-2006, 10:36 AM
    • Sweden
    • Posts 3,543
    • Moderator

    And you get this error even with the ScriptManager declared in your ascx?

    Do you have a script manager also in your Page? Then you need to use a ScriptManagerProxy in your ascx as there can be only one ScriptManager in the page.

    See http://www.asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_ScriptManagerProxy.aspx

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: Popupcontrol extender with user control

    06-12-2008, 12:52 PM
    • Member
      point Member
    • subbarayan
    • Member since 05-27-2008, 12:58 PM
    • Posts 3

    Now I have used the script manager in aspx page only and  set the ScriptManagerProxy in User control. Now I faced a problem.

    It shows web service called failed error.

    pl. help.

  • Re: Popupcontrol extender with user control

    06-18-2008, 5:34 AM
    Answer

    Hi Subbarayan,

    From your description, I understand that you would like to use the DynamicServiceMethod to transform the PopupPanel into a table which is tied to the DataBase.The issue is web service call failed. If I have misunderstood you, please let me know.

    I have tested your code locally and found out the cause is the DynamicServiceMethod is placed at the inappropriate file.

    When your behavior implementation makes a base method call to the "populate" function, the relevant page content will be dynamically updated by the DynamicPopulate control. Population can be done with a page method or a web service and works just as it does when using DynamicPopulate directly. The DynamicServicePath property should be left null if ServiceMethod refers to a page method. So, we need to place the DynamicServiceMethod into some page or web service’s code-behind file. Meanwhile, set the DynamicServicePath with the relational file’s name.

    For example: 

            <ajaxToolkit:PopupControlExtender ID="PoppuExe" runat="server" DynamicContextKey='123'
                DynamicServiceMethod="callfun" TargetControlID="LinkButton1" DynamicControlID="Panel1"
                PopupControlID="Panel1" Position="Bottom" DynamicServicePath="/Default.aspx">
            </ajaxToolkit:PopupControlExtender>
    Have my suggestions resolved your issue?

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
  • Re: Popupcontrol extender with user control

    07-07-2008, 9:37 AM
    • Member
      point Member
    • subbarayan
    • Member since 05-27-2008, 12:58 PM
    • Posts 3

    I had tried with many ways as your code to solve the problem. But not possible.  Pl.  help to use with usercontrol.

  • Re: Popupcontrol extender with user control

    07-07-2008, 10:37 PM

    Hi Subbarayan,

    Please refer to my whole sample code here:

    .aspx file 

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestDynMethod.aspx.vb"
        Inherits="SoluTest_PopupExtender.TestDynMethod" %>
    
    <%@ Register Src="UCTestDynMethod.ascx" TagName="UCTestDynMethod" TagPrefix="uc1" %>
    <!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>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <uc1:UCTestDynMethod ID="UCTestDynMethod1" runat="server" />
        </div>
        </form>
    </body>
    </html>
    .aspx.vb file 
    Partial Public Class TestDynMethod
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
        Public Shared Function ContactList() As String
            Dim strTemp As New StringBuilder()
    
            strTemp.Append("<table>")
            strTemp.Append("<tr><td><b>Contact Info:</b></td></tr>")
    
    
            strTemp.Append("<tr><td>E-Mail :  123@123.com</td></tr>")
            strTemp.Append("<tr><td>Tel No : 12345</td></tr>")
            strTemp.Append("<tr><td>Fax No: 12345</td></tr>")
    
            strTemp.Append("</table>")
            strTemp.Append("<table>")
            strTemp.Append("<tr><td><b>My Contact Info.</b></td></tr>")
            strTemp.Append("</table>")
    
    
            Return strTemp.ToString()
    
        End Function
    
        <System.Web.Script.Services.ScriptMethod()> _
        <System.Web.Services.WebMethod()> _
        Public Shared Function callfun(ByVal contextKey As String) As String
    
            Return ContactList()
        End Function
    
    End Class
    .ascx file 
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="UCTestDynMethod.ascx.vb" Inherits="SoluTest_PopupExtender.UCTestDynMethod" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Label ID="LinkButton1" runat="server" Text="Click"></asp:Label>
            <ajaxToolkit:PopupControlExtender ID="PoppuExe" runat="server" DynamicContextKey='123'
                DynamicServiceMethod="callfun" TargetControlID="LinkButton1" DynamicControlID="Panel1"
                PopupControlID="Panel1" Position="Bottom" DynamicServicePath="/TestDynMethod.aspx">
            </ajaxToolkit:PopupControlExtender>
            <asp:Panel ID="Panel1" runat="server" Width="250px">
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    .ascx.vb file 
    Imports AjaxControlToolkit
    Imports System
    Imports System.Data
    Imports System.Collections
    Imports System.Data.SqlClient
    Imports System.IO
    
    Partial Public Class UCTestDynMethod
        Inherits System.Web.UI.UserControl
    
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
            Dim PropertyId As String = "TN8564565"
    
            Dim pce6 As PopupControlExtender = TryCast(Me.FindControl("PoppuExe"), PopupControlExtender)
    
            ' Set the BehaviorID6
            Dim behaviorID6 As String = String.Concat("pce6", 0)
            pce6.BehaviorID = behaviorID6
            Dim OnMouseOverScript6 As String = String.Format("$find('{0}').showPopup();", behaviorID6)
            Dim OnMouseOutScript6 As String = String.Format("$find('{0}').hidePopup();", behaviorID6)
    
            LinkButton1.Attributes.Add("onmouseover", OnMouseOverScript6)
            LinkButton1.Attributes.Add("onmouseout", OnMouseOutScript6)
            'LinkButton1.Text = "CheckUS"
    
        End Sub
    
    End Class
    Please let me know whether these can help or not.

    Best regards,

    Zhi-Qiang Ni

    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
Page 1 of 1 (6 items)