i have a nestead updatepanel called udp1 which has a menu. by clicking on the items, it will load either an "add.ascx" , "edit.ascx" or "search.ascx". in "add.ascx" i have another updatepanel which the user chooses a topic from a dropdownlist and it will gets the value of the selected index and pass it to a label and some info will be filled automatically to some parts and and some other parts will be filled by the user. my problem is every time i click add from the menu, updatepanel loads the add.ascx file and i can choose the topic from dropdownlist but if in the menu i choose something else (i.e edit) first and then click on add, it will load the add.ascx file but the dropdownlist wont update the label anymore!
here is what i have done till now:
the menu and the first updatepanel:
<asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick" ><Items><asp:MenuItem Text="Add Video" Selected="True"></asp:MenuItem><asp:MenuItem Text="Edit Video"></asp:MenuItem><asp:MenuItem Text="Search Video"></asp:MenuItem></Items></asp:Menu><div class="row"><div class="col-md-12 col-lg-12"><asp:UpdatePanel ID="udp1" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="udp1"><ProgressTemplate>
Loading....</ProgressTemplate></asp:UpdateProgress><asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="Menu1" /></Triggers></asp:UpdatePanel></div></div>code behind:
private const string BASE_PATH = "~/Mod/";
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}
private void LoadUserControl()
{
string controlPath = LastLoadedControl;
if (!string.IsNullOrEmpty(controlPath))
{
PlaceHolder1.Controls.Clear();
UserControl uc = (UserControl)LoadControl(controlPath);
PlaceHolder1.Controls.Add(uc);
}
}
protected void Page_Load(object sender, EventArgs e)
{
LoadUserControl();
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
MenuItem menu = e.Item;
string controlPath = string.Empty;
switch (menu.Text)
{
case "Edit Video":
controlPath = BASE_PATH + "EditVideo.ascx";
break;
case "Search Video":
controlPath = BASE_PATH + "SearchVideo.ascx";
break;
default:
controlPath = BASE_PATH + "AddVideo.ascx";
break;
}
LastLoadedControl = controlPath;
LoadUserControl();
}in addVideo.ascx
<asp:UpdatePanel ID="udp2" runat="server"><ContentTemplate><asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="TutorialSeries" DataTextField="SeriesName" DataValueField="VideoSeriesNameID" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList><br /><asp:SqlDataSource ID="TutorialSeries" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="ViewSeasonName" SelectCommandType="StoredProcedure"></asp:SqlDataSource><asp:Label ID="lblEpisode" runat="server" Text="Label"></asp:Label><br /><asp:TextBox ID="tbxURL" runat="server"></asp:TextBox><br /><asp:TextBox ID="tbxDiscription" runat="server"></asp:TextBox><br /></ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" /></Triggers></asp:UpdatePanel>
code behind:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
lblEpisode.Text = DropDownList1.SelectedValue.ToString();
}can anyone tell me what am i doing wrong here??
thank you in advance