如何访问更新面板外部的控件 [英] how to access the control that outside the update panel

查看:77
本文介绍了如何访问更新面板外部的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ..

我在下拉列表和列表框中使用更新面板,在更新面板外面有一个标签..当标签显示没有数据显示消息时......但是我无法访问更新面板外的标签..



这是我的代码..

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..

<div class="labelerror">
                <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
            </div>













<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>




<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

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";

推荐答案

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





将此添加到上方更新面板。你错过了这个。



Add this somewhere above the update panel. You are missing this.


这篇关于如何访问更新面板外部的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆