Update Panel not updating content

I was trying this from some time, but I am not able to get around it. Following is the code of the aspx page display:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    Test<br />
    <asp:DropDownList ID="DropDownList1" runat="server">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
    </asp:DropDownList>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <br />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>

Following is the code for the button1 click event:

Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        Label1.Text = DropDownList1.SelectedIndex

        UpdatePanel1.Update()

    End Sub
End Class

Could you please tell me what I missed out.

Answers


Set the autopostback to true in the drop down.

The true means: everytime the value in the drop down changes, a postback to the server will occur.

But listen to Tim Schmelter answer. If the drop down will not change, it's a good idea to put it outside the update panel and the update panel must be triggered asynchronous by the drop down (if you don't set a trigger to the update panel, every postback will update your updatepanel). If the content of the dropdown changes, put it inside the updatepanel.

But like I said, I'm not using that for a long time, its a good idea to double check everything I say about the subject. =p

PS: Microsoft Update Panels are easy to develop but make your site very slow. Try to learn about aspnet webservices and jQuery.


Need Your Help

Run Jquery Function on Page Load and on Keyup

javascript jquery

I have been googling this for a while, and can't seem to find an answer :( Simply I have two JQuery functions right now:

jQuery Validate plugin Multiple error placement

javascript jquery jquery-validate

Please help me with jQuery Validate plugin. It is possible to display the error message on custom place?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.