BUG - NumericUpDownExtender in Gridview EditItemTemplate

Last post 11-04-2006 8:50 AM by pierlag_msft. 4 replies.

Sort Posts:

  • BUG - NumericUpDownExtender in Gridview EditItemTemplate

    06-28-2006, 6:53 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335

    Hi there!

    I've just downloaded the latest release of the AtlasControlToolkit and wanted to plumb the NumericUpDownExtender into my Gridview. I want to use it for editing quantities, but it when you put it in an EditItemTemplate, it comes up with an error:

    Assertion Failed: Unrecognized tag atlascontroltoolkit:numericupdownbehavior

    Break into debugger?

    The page I've got this in is rather large, so I've created a mock-up of the scenario to demonstrate the problem. Run the code below, then click on any of the "Edit" buttons and you should get the same error!

    <%@ Page Language="VB" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:XmlDataSource ID="XmlDataSource1" runat="server">
                <Data >
                    <Fruits>
                      <Fruit name="Apples" quantity="5" />
                      <Fruit name="Oranges" quantity="7" />
                      <Fruit name="Bananas" quantity="4" />
                      <Fruit name="Pears" quantity="3" />
                    </Fruits>
                </Data>
            </asp:XmlDataSource>
            <atlas:ScriptManager runat="server" id="scriptManager" EnablePartialRendering="true" />
            <atlas:UpdatePanel ID="UpdatePanel1" runat="server" mode="Always">
                <ContentTemplate>
                    <asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1" AutoGenerateColumns="false" AutoGenerateEditButton="true">
                        <Columns>
                            <asp:TemplateField HeaderText="Fruit">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="Name" Text='<%# XPath("@name") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Quantity">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="Name" Text='<%# XPath("@quantity") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# XPath("@quantity") %>'></asp:TextBox>   
                                    <atlasToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server">
                                        <atlasToolkit:NumericUpDownProperties TargetControlID="TextBox1" Width="120" />
                                    </atlasToolkit:NumericUpDownExtender> 
                                </EditItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </ContentTemplate>
            </atlas:UpdatePanel>
        </div>
        </form>
    </body>
    </html>
    

     One little caveat... YES I do know that the Update will never work for this, as I haven't included any code to handle Updating an XMLDataSource... however, remember this is just a sample case to show the problem... I'm actually getting my real data from an ObjectDataSource with all the correct bits and bobs attached to it so that the updates work!

    OK, so now you've seen the problem, you'll be pleased to know there IS a workaround! Here's what you do... insert the following before the closing </form> tag: 

        <asp:TextBox ID="TextBox1" runat="server" Style="display: none"></asp:TextBox>   
        <atlasToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server">
            <atlasToolkit:NumericUpDownProperties TargetControlID="TextBox1"  />
        </atlasToolkit:NumericUpDownExtender> 
    

    It appears that this "registers" the behavior with the client so that when the Gridview creates the extender when rendering the EditItem it is already there and not a problem! Note the Style="display: none" to make sure the "dummy" textbox is not actually displayed on the client, although it is there!!

    A fix for this would be marvellous, or even a better workaround if someone's got one!

    Cheers,

    James

  • Re: BUG - NumericUpDownExtender in Gridview EditItemTemplate

    06-28-2006, 6:10 PM
    • Member
      41 point Member
    • pierlag_msft
    • Member since 06-05-2006, 12:51 PM
    • Posts 8

    Hi,

    It's a problem with all extenders.
    Context : Use UpdatePanel with EnablePartialRendering="true" and use extender in a template

    Workaround : Just  add Extender with no property at the top of the page for add script in the fist render of the page

  • Re: BUG - NumericUpDownExtender in Gridview EditItemTemplate

    10-25-2006, 9:07 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335

    Hi again!

    I've upgraded my site to the AJAX Beta, and things have stopped working!! I thought I'd try to simply convert what I already had...

    1    <%@ Page Language="VB" %>
    2    
    3    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    4    
    5    <html xmlns="http://www.w3.org/1999/xhtml" >
    6    <head id="Head1" runat="server">
    7        <title>Untitled Page</title>
    8    </head>
    9    <body>
    10       <form id="form1" runat="server">
    11           <asp:ScriptManager runat="server" id="scriptManager" />
    12       <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" />
    13       <div>
    14           <asp:XmlDataSource ID="XmlDataSource1" runat="server">
    15               <Data >
    16                   <Fruits>
    17                     <Fruit name="Apples" quantity="5" />
    18                     <Fruit name="Oranges" quantity="7" />
    19                     <Fruit name="Bananas" quantity="4" />
    20                     <Fruit name="Pears" quantity="3" />
    21                   </Fruits>
    22               </Data>
    23           </asp:XmlDataSource>
    24           <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
    25               <ContentTemplate>
    26                   <asp:GridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1" AutoGenerateColumns="false" AutoGenerateEditButton="true">
    27                       <Columns>
    28                           <asp:TemplateField HeaderText="Fruit">
    29                               <ItemTemplate>
    30                                   <asp:Label runat="server" ID="Name" Text='<%# XPath("@name") %>'></asp:Label>
    31                               </ItemTemplate>
    32                           </asp:TemplateField>
    33                           <asp:TemplateField HeaderText="Quantity">
    34                               <ItemTemplate>
    35                                   <asp:Label runat="server" ID="Name" Text='<%# XPath("@quantity") %>'></asp:Label>
    36                               </ItemTemplate>
    37                               <EditItemTemplate>
    38                                   <asp:TextBox ID="TextBox1" runat="server" Text='<%# XPath("@quantity") %>'></asp:TextBox>   
    39                                   <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="TextBox1" Width="120" />
    40                               </EditItemTemplate>
    41                           </asp:TemplateField>
    42                       </Columns>
    43                   </asp:GridView>
    44               </ContentTemplate>
    45           </asp:UpdatePanel>
    46       </div>
    47       </form>
    48   </body>
    49   </html>
    

    Unfortunatley, this doesn't work because "The TargetControlID of 'NumericUpDownExtender1' is not valid. The value cannot be null or empty." Big Smile

    So I thought, perhaps I don't need the additional extender at the top... maybe it's fixed... so I removed line 12 and gave it a whirl. Initially that looks good, until you click on Edit on one of the rows, and then the up/down buttons don't appear. Surprise

    My next idea was to revert back to my original solution of adding an invisible text box, hoping that this would work. So I replaced line 12 with:

        <asp:TextBox ID="TextBox1" runat="server" Style="display: none"></asp:TextBox>
        <ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="TextBox1" />
    

     But that's not the answer either Angry

    And then I found out something even more strange!! By adding a RangeValidator and turning off client-side script (don't ask how I found this one!!), you can get the up down buttons to appear. Here's how to do it:

    Firstly, insert the following line of code just prior to the end of the </EditItemTemplate> at line 40

         <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1" MinimumValue="10" MaximumValue="99" Type="Integer" EnableClientScript="false">*</asp:RangeValidator>                            
    

     This forces a round trip to the server to validate the quantity, which will be invalid unless it is between 10 and 99.

    Secondly, take these steps:

    1) Load the new page

    2) Click on Edit (NB the up/down buttons aren't there yet!)

    3) Click on Update

    At this point, the validation will have failed, but the up/down buttons miraculously appear!!!!

    Confused??? Me too!!! Confused

    Has anyone got any idea how I can solve this please?

    Thanks,

    James

  • Re: BUG - NumericUpDownExtender in Gridview EditItemTemplate

    10-27-2006, 7:07 AM
    • Participant
      1,526 point Participant
    • James_2JS
    • Member since 02-13-2006, 3:21 PM
    • Posts 335

    Looks like this has been answered here. It seems as though AJAX Beta v1 is fatally floored!!

    I simply cannot use it.

  • Re: BUG - NumericUpDownExtender in Gridview EditItemTemplate

    11-04-2006, 8:50 AM
    • Member
      41 point Member
    • pierlag_msft
    • Member since 06-05-2006, 12:51 PM
    • Posts 8
Page 1 of 1 (5 items)