I am facing a problem with the updatepanel.
I am using a ASP menu control. I have a lable control within an UpdatePanel.
Upon clicking the menu , I pick the selectedvalue and display as lable text. My code works but whenever I click I get the previously selected value in the lable and not the latest one.
For ex:I have Item1,Item2,Item3 and Item4 in my menu
Upon loading I click Item1 the lable does not refresh.
Then I click on Item3 this time the lable refreshes but shows the previously selected value i.e:Item1.
Then I click on Item2 this time the lable refreshes but again shows the previously selected value i.e:Item3.:mad: X|
Below is my aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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">
<div>
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem Text="Item1" Value="Item1"></asp:MenuItem>
<asp:MenuItem Text="Item2" Value="Item2"></asp:MenuItem>
<asp:MenuItem Text="Item3" Value="Item3"></asp:MenuItem>
<asp:MenuItem Text="Item4" Value="Item4"></asp:MenuItem>
</Items>
</asp:Menu>
<asp:ScriptManager ID="ScriptManager1"
runat="server" />
<asp:UpdatePanel ID="UpdatePanel1"
UpdateMode="Conditional"
runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Menu1" />
</Triggers>
<ContentTemplate>
<fieldset>
<asp:Label ID="Label1" runat="server"
ForeColor="White" Font-Size="Large" BackColor="#00447b" Width="700px" ></asp:Label>
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
this is my code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Menu1.SelectedItem != null)
Label1.Text = Menu1.SelectedValue;
}
}
Please provide me some help on this.