PopupControlExtender applied to RadioButtonList in DataGrid

Last post 11-08-2007 11:28 AM by jon.ebersole. 1 replies.

Sort Posts:

  • PopupControlExtender applied to RadioButtonList in DataGrid

    07-31-2007, 6:56 PM
    • Member
      20 point Member
    • swdev
    • Member since 03-19-2007, 12:10 PM
    • Posts 12

    I have a DataList control which in its ItemTemplate contains (amoungst many other things) a RadioButtonList and a UserControl. I've simplified the code for brevity but it goes something like this:

     

    <asp:DataList ID="dlAktivForm" runat="server" Width="100%" OnItemDataBound="dlAktivForm_ItemDataBound">
                                        <ItemTemplate>
                                            <table style="width: 100%" border="0" bgcolor="white" cellpadding="1" cellspacing="1">
                                                <tr>
                                                    <td colspan="4">
                                                        <asp:Table runat="server" Style="width: 100%" ID="FormSectionHeader" CssClass="TableHeader"
                                                            HorizontalAlign="Left" BorderWidth="1">
                                                            <asp:TableRow ID="TableRow1" runat="server" HorizontalAlign="Left">
                                                                <asp:TableCell runat="server" ID="FormSectionNumber" HorizontalAlign="Left" Width="20"></asp:TableCell>
                                                                <asp:TableCell runat="server" ID="FormSectionTitle" HorizontalAlign="Left"></asp:TableCell></asp:TableRow>
                                                        </asp:Table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="height: 21px" bordercolor="white" width="50">
                                                        <asp:Label ID="lblSectionNumber" runat="server" CssClass="FieldNamesIndented"></asp:Label>.
                                                        <asp:Label ID="lblQuestionNumber" runat="server" CssClass="Text11pt" Text='<%# Eval("QuestionNumber") %>'></asp:Label>
                                                    </td>
                                                    <td style="height: 21px" bordercolor="white">
                                                        <asp:Label ID="lblQuestionID" runat="server" Font-Bold="True" CssClass="Text11pt"
                                                            Text='<%# Eval("QuestionID") %>' Visible="false"></asp:Label>
                                                        <asp:Label ID="Label2" runat="server" CssClass="Text11pt" Text='<%# Eval("Question") %>'></asp:Label></td>
                                                    <td align="right">
                                                        <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
                                                            AutoPostBack="False" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
                                                            CssClass="FieldNamesIndented">
                                                        </asp:RadioButtonList>
                                                        <uc3:AjaxPopUp ID="AjaxPopUp1" runat="server" />
                                                        <asp:CheckBoxList ID="CheckBoxList1" runat="server" CssClass="FieldNamesIndented"
                                                            RepeatDirection="Horizontal">
                                                        </asp:CheckBoxList>
                                                        <asp:TextBox ID="TextBox1" runat="server" Columns="30" Font-Bold="False" Rows="5"
                                                            TextMode="MultiLine"></asp:TextBox>
                                                        <cc1:HorizontalTextBoxList ID="htbl" runat="server" Width="600" HeaderText="Data Entry"
                                                            BackColor="#DCEBF1" BorderStyle="solid" BorderWidth="1">
        <formfield id="ffSted" Label="Sted/Enhet" />
        <formfield id="ffProdukt" Label="Produkt" />
        <formfield id="ffTemp" Label="Temp" />    
        <formfield id="ffKarakter" Label="Karakter" />
        <symbolfield id="sfSymbol" Label="" URL="/images/icons/white.gif"/>
        
           
                                                        </cc1:HorizontalTextBoxList>
                                                        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upnlTemp"
                                                            Visible="false">
                                                            <ProgressTemplate>
                                                                <div class="Text11ptBoldRed">
                                                                    <img src="/images/loading1.gif" /> Temperature symbols updating...
                                                                </div>
                                                            </ProgressTemplate>
                                                        </asp:UpdateProgress>
                                                        <cc1:HorizontalTextBoxList ID="htbl2" runat="server" Width="600" HeaderText="Data Entry"
                                                            BackColor="#DCEBF1" BorderStyle="solid" BorderWidth="1">
        <formfield id="ffPrøvetaksted" Label="Prøvetaksted" />
        <formfield id="ffAnalysepreperat" Label="Analysepreperat" />
        <formfield id="ffAnalysesvar" Label="Analysesvar" />
        <dropdownlistfield id="ddlfKarakter" Label="Karakter" />
        <symbolfield id="sfSymbol2" Label="" URL="/images/icons/white.gif" />
                                                        </cc1:HorizontalTextBoxList>
                                                    </td>
                                                </tr>
                                            </table>
                                            <asp:HiddenField ID="hfAnswerType" runat="server" Value='<%# Eval("AnswerType") %>' />
                                            <asp:HiddenField ID="hfSectionID" runat="server" Value='<%# Eval("FormSectionID") %>' />
                                            <asp:HiddenField ID="hfRuleID" runat="server" Value='<%# Eval("RuleID") %>' />
                                        </ItemTemplate>
                                        <HeaderTemplate>
                                        </HeaderTemplate>
                                        <FooterTemplate>
                                            <br />
                                            <br />
                                        </FooterTemplate>
                                    </asp:DataList>




    Now my UserControl has the following code:

     
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="AjaxPopUp.ascx.cs" Inherits="AjaxPopUp" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
    <asp:Panel ID="Panel2" runat="server" CssClass="popupControl" Visible="true">
        <asp:UpdatePanel ID="upnlPopUp" runat="server">
            <ContentTemplate>
                <table align="center" width="400" border="0" cellpadding="0" cellspacing="0" bgcolor="silver">
                    <tr>
                        <td align="left" valign="top">
                            <table width="400" border="0" cellpadding="3" cellspacing="1">
                                <tr>
                                    <td colspan="5" class="TableHeader" height="15">
                                        <div align="center" class="Text11ptBold">
                                            Handlingsplan for lukking av avvik</div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="200" class="TableHeader">
                                        Beskrivelse avvik</td>
                                    <td width="100" align="left" valign="middle" class="TableHeader">
                                        Tiltak</td>
                                    <td width="100" align="left" valign="middle" class="TableHeader">
                                        Ansvar</td>
                                    <td width="10" align="left" valign="middle" class="TableHeader">
                                        Frist
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#FFFFFF" class="FieldNamesIndented">
                                        <asp:TextBox ID="tbAvvik" runat="server" Width="131px" AutoPostBack="false"></asp:TextBox></td>
                                    <td bgcolor="#FFFFFF">
                                         <asp:TextBox ID="tbTiltak" runat="server" Width="95px" AutoPostBack="false"></asp:TextBox></td>
                                    <td bgcolor="#FFFFFF">
                                         <asp:TextBox ID="tbAnsvar" runat="server" Width="95px" AutoPostBack="false"></asp:TextBox></td>
                                    <td align="center" valign="middle" bgcolor="#FFFFFF" class="Text11ptBoldGreen">
                                        <asp:TextBox ID="tbFrist" runat="server" Width="16px" AutoPostBack="false"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td colspan="4" bgcolor="white" class="Text11ptBoldRed">
                                        <%--<asp:UpdateProgress ID="Process1" runat="server">
                                            <ProgressTemplate>
                                            <div>                                           
                                                    <img src="/images/loading1.gif" />&nbsp;Handlingsplan is updating...
                                             </div>    
                                            </ProgressTemplate>
                                        </asp:UpdateProgress>--%>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <ajaxToolkit:PopupControlExtender ID="PopupControlExtender2" runat="server" TargetControlID="RadioButtonList1"
        PopupControlID="Panel2" CommitProperty="e.value" Position="top" OffsetX="-420"
        OffsetY="-25" CommitScript="e.value += ' - whatever';"  />
     
     My problem is that I want to suppress the AjaxPopup control depending on which RadioButton is clicked. Currently the popup occurs on every RadioButton Click.
    I've tried stuff like :

     
    <ajaxToolkit:PopupControlExtender  ID="PopupControlExtender2" runat="server" TargetControlID="RadioButtonList1"
        PopupControlID="Panel2" Position="top" OffsetX="-420"
        OffsetY="-25" DynamicServiceMethod="GetDynamicContent" DynamicContextKey="x"
     DynamicControlID="Panel2"  DynamicServicePath="/Admin/FormSelection/AjaxPopUpWebService.asmx"   />--%>
     <%--  ID="PopupControlExtender1" runat="server" TargetControlID="RadioButtonList1"
        PopupControlID="Panel2" Position="top" OffsetX="-420"
        OffsetY="-25" DynamicServiceMethod="GetDynamicContent" DynamicContextKey="x"
     DynamicControlID="Panel2" />
     <>and writing a DynamicService method either using a webservice or in the page-behind of the control but always get a 'cant find method' error.
    I'm a fairly experienced developer but this is driving me nuts. Please can someone help
    Thanks swDevg
  • Re: PopupControlExtender applied to RadioButtonList in DataGrid

    11-08-2007, 11:28 AM
    • Member
      31 point Member
    • jon.ebersole
    • Member since 06-26-2002, 8:58 AM
    • Pennsylvania, USA
    • Posts 38

    I ran into the same problems with breaking out the popupControlExtender's DynamicServiceMethod into its own webservice .vb file, and this is what I did to fix them...

    First in my webservice I added the following line to the CLASS as described in the article above...

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

    Next, I removed the junk from the GetDynamicContent method. VisualStudio puts this stuff in the file when that method is automatically created within the page...

    <System.Web.Services.WebMethod()> _
    <System.Web.Script.Services.ScriptMethod()> 
    I simply changed it to... 
    <WebMethod()>
     If you want session state to be available, do this instead...
    <WebMethod(EnableSession:=True, BufferResponse:=True, CacheDuration:=0)>

    Then, I removed 'Shared' from the method so it was no longer a Shared method.

    Because my webservices are in a different subfolder than my main project called 'webservices' I added this to my DynamicServicePath property. I think one important thing to note here is that this path must include the name of the asmx file AND include the extension. Mine looks like this...
    DynamicServicePath="/WebServices/DynamicImageService.asmx"

    Then, we make our DynamicServiceMethod equal to the actual method name...
    DynamicServiceMethod="GetDynamicContent"

    Some articles tell you to make sure this isn't in your web.config
    <remove verb="*" path="*.asmx"/>

    I found this to be a bogus request, because it appears later in the config enabling it for scripting. Mine worked fine as so... 

    <httpHandlers>
       <remove verb="*" path="*.asmx"/>
       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
       <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>
    

    I hope this helps you in your situation above. It sounds like you have a very similar problem.

     

    Thanks,
    Jon Ebersole
Page 1 of 1 (2 items)