2012-07-09 96 views
0

我有一个asp.net下拉控件,其中添加了工具提示。它可以在鼠标上正常工作。我在该页面也有一个Modal Popup。当我打开并关闭Modal Popup时,不再显示下拉菜单中的工具提示。打开模式弹出窗口时不显示asp.net下拉工具提示

以下是我的代码。

背后

foreach (ListItem item in DdlSupplier.Items) 
      { 
       item.Attributes.Add("title", item.Text); 
      } 
      DdlSupplier.Attributes.Add("onmouseover","this.title=this.options[this.selectedIndex].title"); 

点击lnkAddSupplier

 <div class="col"> 
      <div class="labelname required"> 
       <asp:Label ID="lblsupplier" runat="server" Text="Supplier"></asp:Label> 
      </div> 
      <div class="labelvalue"> 
       <asp:DropDownList ID="DdlSupplier" TabIndex="11" runat="server" AutoPostBack="true" 
        CausesValidation="false" OnSelectedIndexChanged="DdlSupplier_SelectedIndexChanged"> 
       </asp:DropDownList> 
       <asp:RequiredFieldValidator ID="reqSupplier" runat="server" ControlToValidate="DdlSupplier" 
        ValidationGroup="SubmitGroupMain" InitialValue="0" ErrorMessage="Please Select Supplier Name" 
        SetFocusOnError="true" Display="None"></asp:RequiredFieldValidator> 
       <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender7" runat="Server" 
        TargetControlID="reqSupplier" HighlightCssClass="validatorCalloutHighlight"> 
       </ajaxToolkit:ValidatorCalloutExtender> 
      </div> 
      <asp:LinkButton runat="server" ID="lnkAddSupplier" CssClass="btnadd" ToolTip="New Supplier" 
       OnClick="lnkAddSupplier_Click"></asp:LinkButton> 
      <asp:Button runat="server" ID="popupshowAccount" Style="display: none" /> 
     </div> 
    </div> 

代码打开了一个弹出窗口。关闭弹出式工具提示后,下拉菜单不可见。

请帮忙解决这个问题。

+0

份额相关的标记和代码来支持你的问题。 – 2012-07-09 06:50:19

回答

0

属性不会保存在Viewstate中,这就是为什么它们会在回传中消失的原因。自定义属性的情况类似。

这就是为什么我们要使用DropDownList的预渲染事件来设置属性

protected void DropDownList1_PreRender(object sender, EventArgs e) 
{ 
    foreach (ListItem item in DropDownList1.Items) 
     item.Attributes.Add("title", "Something to test!!!!!!"); 
} 
相关问题