Updatepanel Button Async issue - Won't properly register control

Last post 04-09-2009 11:31 AM by skrile. 5 replies.

Sort Posts:

  • Updatepanel Button Async issue - Won't properly register control

    04-09-2009, 9:47 AM
    • Member
      82 point Member
    • skrile
    • Member since 11-05-2003, 10:30 AM
    • Posts 43

    I'm having a weird problem and need some assistance in troublshooting.  I have a very simple page.  

     

    1    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="test.aspx.vb" Inherits="HSE.test" %>
    2    <%@ Register
    3        Assembly="AjaxControlToolkit"
    4        Namespace="AjaxControlToolkit"
    5        TagPrefix="cc1" %>
    6    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    7    
    8    <html xmlns="http://www.w3.org/1999/xhtml" >
    9    <head runat="server">
    10       <title>Untitled Page</title>
    11   </head>
    12   <body>
    13       <form id="form1" runat="server">
    14           <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release" />
    15   
    16           <asp:UpdatePanel runat="server" UpdateMode="conditional" ID="updatePanel" ChildrenAsTriggers="False">
    17               <Triggers>
    18                   <asp:AsyncPostBackTrigger ControlID="button1" EventName="Click" />
    19               </Triggers>
    20               <ContentTemplate>
    21                   <asp:ObjectDataSource runat="server" ID="TestData" TypeName="HSE.HSMS"
    22                       SelectMethod="GetHoursWorked">
    23                       <SelectParameters>
    24                           <asp:Parameter Name="ReportDate" DefaultValue="12/31/2008" />
    25                       </SelectParameters>    
    26                   </asp:ObjectDataSource>
    27                   <asp:Label runat="server" ID="label1" />
    28                   <asp:LinkButton runat="server" ID="button1" Text="update" OnClick="button1_Click" />
    29                   <asp:GridView runat="server" ID="PlantOpsview" 
    30                       AllowSorting="true" AutoGenerateColumns="true" 
    31                       DataSourceID="TestData" EnableSortingAndPagingCallbacks="true" />
    32               </ContentTemplate>
    33               <Triggers>
    34                   <asp:AsyncPostBackTrigger ControlID="button1" />
    35               </Triggers>
    36           </asp:UpdatePanel>
    37   
    38       </form>
    39   </body>
    40   </html>
    41   
    

      

    Here is the code behind:

     

    1    Partial Public Class test
    2        Inherits System.Web.UI.Page
    3    
    4        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    5            
    6
    7 End Sub 8 9 Protected Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 10 label1.Text = Now.ToString() 11 End Sub 12 End Class

      

    So, now for the issue.  the GridView works great.  Headers do the AsyncPostBack just fine.  The link is rendered as:

     <a onclick="javascript:__gvPlantOpsview.callback("0|0|/wEFCEZhY2lsaXR5Iv92yJF8LRbuYb4o9BmAd5EGb9k=|"); return false;" href="javascript:__doPostBack('PlantOpsview','Sort$Facility')">Facility</a>

      

    But the button is rendered as:

      

    <a id="button1" href="javascript:__doPostBack('button1','')">update</a>
    
     

     No callback event is wired up.  Please tell me I'm missing something obvious.  I've cut and past this code into a new test project and IT WORKS?!?!  But not in my current project.  How is this possible?

  • Re: Updatepanel Button Async issue - Won't properly register control

    04-09-2009, 10:06 AM
    • Participant
      1,399 point Participant
    • jagjot
    • Member since 10-19-2006, 9:02 AM
    • United Kingdom
    • Posts 749

    try using button instead of linkbutton or try to add handler in your  button1_Click

     

    Jagjot Singh
    MCP, CCNA
  • Re: Updatepanel Button Async issue - Won't properly register control

    04-09-2009, 10:12 AM
    • Member
      82 point Member
    • skrile
    • Member since 11-05-2003, 10:30 AM
    • Posts 43

     I have tried using a Button instead - no luck.

     Add a Handler?  What do you mean by that...example?

     

    I shouldn't have to add anything to anything to get the updatepanel to fire...no?

  • Re: Updatepanel Button Async issue - Won't properly register control

    04-09-2009, 10:19 AM
    • Participant
      1,399 point Participant
    • jagjot
    • Member since 10-19-2006, 9:02 AM
    • United Kingdom
    • Posts 749

    try adding button1.click

    Protected Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click

      label1.Text = Now.ToString()

    End Sub

    Jagjot Singh
    MCP, CCNA
  • Re: Updatepanel Button Async issue - Won't properly register control

    04-09-2009, 10:57 AM
    • Member
      82 point Member
    • skrile
    • Member since 11-05-2003, 10:30 AM
    • Posts 43

     The code *works*.  I already have a handler for the click event:

     

    9        Protected Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    10 label1.Text = Now.ToString()
    11 End Sub

     

     

    Adding button1_click changed nothing.

  • Re: Updatepanel Button Async issue - Won't properly register control

    04-09-2009, 11:31 AM
    Answer
    • Member
      82 point Member
    • skrile
    • Member since 11-05-2003, 10:30 AM
    • Posts 43

    Sometimes a chainsaw is the best approach.  After slicing a scalpal through my web.config and references ad nauseum, I did the sensible thing and started my project over....problem solved.

Page 1 of 1 (6 items)