[RESOLVED] UpdatePanel works strange
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: [RESOLVED] UpdatePanel works strange

  1. #1
    Join Date
    Aug 2009
    Posts
    27

    [RESOLVED] UpdatePanel works strange

    Dear experts,

    I have an UpdatePanel and some controls within it, as you can see below. If I change a number in txtGoToPage textbox and press Enter, GoToPage_TextChanged() event handler is called. But if I enter first any page number other than 1, press Enter, and then enter number 1 again, after pressing Enter GoToPage_TextChanged() is not called. The same problem exists with ddlPageSize dropdown list. As you can see, by default the third item is selected. If I select another item, ddlPageSize_SelectedIndexChanged() is called, but if after that I select the third (initially selected) item, ddlPageSize_SelectedIndexChanged() is not called.

    Could you please help me fix that?

    Thanks.

    Code:
        <asp:UpdatePanel ID="upnlLicensing" runat="server" UpdateMode="Conditional" >
            <ContentTemplate>
    ...
                <asp:Label ID="Label1" runat="server" Text="Show rows:" />
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true"
                    OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged">
                    <asp:ListItem Value="20" />
                    <asp:ListItem Value="50" />
                    <asp:ListItem Value="100" Selected="True" />
                </asp:DropDownList>
                &nbsp;
                Page 
                <asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" 
                    OnTextChanged="GoToPage_TextChanged" CssClass="gotopage" onchange="JSSetSessionValue('ReloadLicensing', true);JSSetSessionValue('NewPageNumber', this.value)" />
                of
                <asp:Label ID="lblTotalNumberOfPages" runat="server" />
                    
            </ContentTemplate>
        </asp:UpdatePanel>

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,771

    Re: UpdatePanel works strange

    Okay a few things..

    With a ASP textbox, If you enter the same info that was in the box in the first place it does not trigger the change events.. (ASP applications have a different set of rules to Desktop applications).. and the same goes for DDL's if you select the same item that was set as default, a changed event does not trigger...

    A work around is to normally add a "[Please Select one]" item to the DDL and set it as default, and clear the Textbox, every time the page loads..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Aug 2009
    Posts
    27

    Re: UpdatePanel works strange

    Thank you for your answer. But my problem was not that that I was trying to trigger an event without making any change. The default value was selected (or entered in case of textbox) originally, but not immediately before the currently selected value, so a change has taken place.
    And everything worked before I added UpdatePanel.
    But I found the solution:
    http://stackoverflow.com/questions/1...in-updatepanel

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,771

    Re: UpdatePanel works strange

    Cool .. Dont forget to mark this thread resolved....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Aug 2009
    Posts
    27

    Re: UpdatePanel works strange

    May I ask how I can mark this thread as resolved?
    Thanks.

  6. #6
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,771

    Re: UpdatePanel works strange

    Quote Originally Posted by dpreznik View Post
    May I ask how I can mark this thread as resolved?
    Thanks.
    Just above the first post .. Thread Tools -> Mark thread Resolved...


    Cheers ..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center