ModalPopUp with DynamicServiceMethod in a Web User Control

Last post 11-07-2006 5:27 PM by Ziax. 1 replies.

Sort Posts:

  • ModalPopUp with DynamicServiceMethod in a Web User Control

    09-20-2006, 3:54 AM
    • Member
      169 point Member
    • Ziax
    • Member since 03-08-2006, 1:18 PM
    • Posts 44

    I followed this example: http://blogs.msdn.com/delay/archive/2006/09/19/762609.aspx and it works perfectly.

    If recreate the page as a Web User Control and use it on another page, the webservice failed to execute.

    Page: 

    <%@ Page Language="C#" MasterPageFile="~/Loggen.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
        Inherits="Default2" Title="Untitled Page" %>
    <%@ Register TagPrefix="test" src="~/WebUserControl.ascx" TagName="WebUserControl" %>    

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentMainWindow" runat="Server">
    <test:WebUserControl runat="server" ID="aa" />
    </asp:Content>

     

    Web User Control:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>

        <%-- A very simple data source to drive the demonstration --%>
        <asp:XmlDataSource ID="XmlDataSource1" runat="server">
          <Data>
            <items>
              <item style='font-weight:bold' />
              <item style='font-style:italic' />
              <item style='text-decoration:underline' />
            </items>
          </Data>
        </asp:XmlDataSource>

        <%-- A simple list of all the data items available --%>
        <asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">

          <HeaderTemplate>
            How would you like your dynamic content styled?
          </HeaderTemplate>

          <ItemTemplate>
            &bull; <asp:LinkButton ID="LinkButton" runat="server" Text='<%# Eval("style") %>' />

            <%-- The ModalPopupExtender, popping up Panel1 and dynamically populating Panel2 --%>
            <atk:ModalPopupExtender ID="ModalPopupExtender" runat="server">
              <atk:ModalPopupProperties
                TargetControlID="LinkButton" PopupControlID="Panel1" OkControlID="Button1"
                BackgroundCssClass="modalBackground" DynamicControlID="Panel2"
                DynamicContextKey='<%# Eval("style") %>' DynamicServiceMethod="GetContent" />
            </atk:ModalPopupExtender>
          </ItemTemplate>

        </asp:DataList>

        <%-- All ModalPopups share the same popup --%>
        <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" style='display:none;'>
          <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p>
          <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>
        </asp:Panel>

    And codefile:

    ublic partial class WebUserControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [System.Web.Services.WebMethod]
        public string GetContent(string contextKey)
        {
            // Create a random color
            string color = (new Random()).Next(0xffffff).ToString("x6");
            // Use the style specified by the page author
            string style = contextKey;
            // Display the current time
            string time = DateTime.Now.ToLongTimeString();
            // Compose the content to return
            return "<span style='color:#' + color + '; ' + style + ''>' + time + '</span> ';
        }

    }

    How to make it execute in a user control? The error is: WebService call failed: 500

     

    Cheers 

  • Re: ModalPopUp with DynamicServiceMethod in a Web User Control

    11-07-2006, 5:27 PM
    • Member
      169 point Member
    • Ziax
    • Member since 03-08-2006, 1:18 PM
    • Posts 44

    Still have the problem. Any ideas?

     

    Ziax 

Page 1 of 1 (2 items)