<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="DocNew.aspx.cs" Inherits="DocNew" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
</head>
<body>
    <img id="img1"/>
    <div id="div1" runat="server" style="display:none">
            <asp:DropDownList ID="dpl_file_cat" runat="server" class="tx" Height="25px" Width="100px">
               <asp:ListItem Value=""></asp:ListItem>
               <asp:ListItem Value="1">Y</asp:ListItem>
               <asp:ListItem Value="0">N</asp:ListItem>
             </asp:DropDownList>
   </div>
</body>
$("#img1").click(function(){
   $("#div1").show();
})问题是:显示出来的div1中的DropDownList不可用,点击没有反应,下拉框都没有。

解决方案 »

  1.   

    我将 div1的display:none 去掉,dropdownlist又是可用的还有一种情况,我将<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    这条语句去掉,dropdownlist也是可用的
      

  2.   

    本帖最后由 net_lover 于 2011-12-08 16:25:15 编辑
      

  3.   

    代码测试没问题。Ie9,ff8下均正常<!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 id="Head1" runat="server">
      <title></title>
      <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    </head>
    <body>
      <form runat="server">
      <img id="img1" src="http://dotnet.aspx.cc/Images/logoSite.gif" />
      <div id="div1" runat="server" style="display: none">
        <asp:DropDownList ID="dpl_file_cat" runat="server" class="tx" Height="25px" Width="100px">
          <asp:ListItem Value=""></asp:ListItem>
          <asp:ListItem Value="1">Y</asp:ListItem>
          <asp:ListItem Value="0">N</asp:ListItem>
        </asp:DropDownList>
      </div>
      </form>
      <script>
        $("#img1").click(function () { $("#div1").show(); }) 
      </script>
    </body>
    </html>
      

  4.   

    是的 界面上有一个img按钮,点击它弹出隐藏的<div id="div1">  
      

  5.   

    本帖最后由 net_lover 于 2011-12-08 16:32:24 编辑
      

  6.   


      <asp:TemplateField HeaderText="">
     <ItemStyle Wrap="False" HorizontalAlign="Center" VerticalAlign="Middle" />
     <HeaderStyle Wrap="False" Width="50px" />
      <ItemTemplate>
     <asp:Image ID="imgdetail" ImageUrl="images/folder.gif" runat="server" ToolTip="查看文檔詳細" Style="cursor: pointer" doc_id='<%# Eval("DocID") %>' status='<%# Eval("Status") %>' />
      </ItemTemplate>
    </asp:TemplateField>服务器控件asp:Image,放在GridView中的
      

  7.   

    this.dropdownlist.Autoposback =true;
      允许回发!
      

  8.   


    就是说嘛,你的代码跟问题是完全不同的。你应该在绑定事件里面,获得Image1.ClientID,设置给$("#<%=Image1.ClientID%>").click(function(){
       $("#div1这里也一样").show();
    })GridView里面的id已经变了!!!!
      

  9.   

    点击这个按钮   $("#GridView1").find("tr:not(:first)").find("td:eq(3)").find("img").click(function()
       {
      $("#detail_grid").show();
    }
    弹出一个详细信息的表格
    这个表格里面有一个<Button id="add_item">按钮  点击这个按钮弹出那个带有dropdownlist的框,这个框里面dropdownlist不可用
      

  10.   

    也就是有两个框,第二个框通过<Button id="add_item">按钮,在js里面操作show()
    第二个框里的dropdownlist不起作用
      

  11.   

    本帖最后由 net_lover 于 2011-12-08 17:01:35 编辑
      

  12.   

    少了一步
    $(document).ready(
       $('#GridView1 img').each(function () {  //通过GridView里面的asp:img弹出div_first
       $(this).click(function () {
                         //这里需要先弹出一个div_first,这个div中有个<Button id="btn_add">,点击它弹出div1,dropdownlist在div1中
       $("#div1").show();//通过div_first里面的<Button id="btn_add">弹出div1
       });
       })); 
      

  13.   

    不会是服务器控件ID变化这个问题应该,js先加载,页面是后加载的