Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
heyy..
I use a update panel inside that dropdown and a listbox and outside the update panel a label is there ..When No data the label show show a message ...but I could not access the label that is outside the update panel..

here is my code..
XML
<div class="labelerror">
                <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
            </div>




XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <div class="boxcolwideroute" runat ="server" id="Idboxcolwideroute">
                        <asp:DropDownList ID="ddlRoute" runat="server" attr-identity="ddlRoute" CssClass="aspcombobox">
                            <asp:ListItem Value="-1">--Select--</asp:ListItem>
                        </asp:DropDownList>
                        <asp:ImageButton runat="server" ID="imageAdd" ImageUrl="~/Images/add_16.png" Style="width: 16px"
                            OnClick="imageAdd_Click" />
                    </div>

XML
<div class="boxcolroute" runat="server" id="Idboxcolroute">
                        <span class="lbltxt">Selected Routes</span> <span class="validation">*</span>
                    </div>
                    <div class="boxcolwide2" runat="server" id="Idboxcolwide2">
                        <%-- <asp:DropDownList ID="ddlroutes" runat="server" attr-identity="ddlRoute" CssClass="aspcombobox">
                    <asp:ListItem Value="-1">--Select--</asp:ListItem>
                </asp:DropDownList>--%>
                        <asp:ListBox ID="lstRoutes" runat="server" SelectionMode="Multiple"></asp:ListBox>
                        <asp:ImageButton runat="server" ID="imgCancel" ImageUrl="~/Images/minus_16.png" Style="width: 16px"
                            OnClick="imgCancel_Click" />
                    </div>
                </ContentTemplate>
            </asp:UpdatePanel>



My Code

C#
if (lstRoutes.Items.Count > 0 && lstRoutes.SelectedIndex >= 0)
          {
              for (int i = 0; i < lstRoutes.Items.Count; i++)
              {
                  if (lstRoutes.Items[i].Selected)
                  {
                      lstRoutes.Items.Remove(lstRoutes.Items[i]);
                      i--;
                  }
              }

              if (lstRoutes.Items.Count > 0)
                  lstRoutes.SelectedIndex = 0;
          }
          else
              lblMessage.Text = "No Route Selected";
Posted
Updated 16-Apr-13 0:53am
v2
Comments
PrashantSonewane 16-Apr-13 6:56am    
where is your asp:Lable in given HTML code? I am not seeing it. Make sure you have that inside the <form> tag. Code behind will find it anyway.
aravindnass 16-Apr-13 7:20am    
no..I add already...plz give a solution..

1 solution

ASP.NET
<asp:Label runat="server" ID="lblMessage"></asp:Label>


Add this somewhere above the update panel. You are missing this.
 
Share this answer
 
Comments
aravindnass 16-Apr-13 7:20am    
no..I add already...plz give a solution..
PrashantSonewane 16-Apr-13 7:30am    
And you are sure that is inside the <form> tag. Please check once. There shouldn't be any reason why lable is not accessible.
aravindnass 16-Apr-13 7:55am    
the label is accessible ,but when I write lblMessage.text="No Route Selected"..the text is not appear..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900