部分代码:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
 <ContentTemplate>
                         <asp:Repeater ID="RepeaterNote" runat="server" OnItemCommand="RepeaterNote_ItemCommand">
                                      <HeaderTemplate>
                                         <table cellspacing="0" cellpadding="0" width="100%">
                                           <tr>
                                              <td width="75%" align="left"> &nbsp; </td>
                                              <td width="25%" align="left"><font size="Large">最后修改时间</font></td>
                                           </tr>
                                      </HeaderTemplate>
                                     
                                      <ItemTemplate>
                                            <tr>
                                               <td>      
                                                   <asp:Label ID="lblNoteId" runat="server" Text='<%# Eval("id") %>' Visible=false></asp:Label>
                                                   <asp:CheckBox ID="chkID" runat="server" />    &nbsp;          
                        <asp:LinkButton ID="btnNote" CommandName="shownote" CommandArgument=<%# Eval("id") %> Font-Size="Large" Width="90%" runat="server"><%# DataBinder.Eval(Container.DataItem, "Title")%></asp:LinkButton>
                                               </td>
                                               <td>
                                                  <asp:Label ID="lblLastEditDate" Text='<%# Eval("LastEditDate")%>' runat=server Font-Size="Large"></asp:Label>
                                               </td>
                                            </tr>
                                      </ItemTemplate>
                                     
                                      <FooterTemplate>
                                         </table>
                                      </FooterTemplate>
                        </asp:Repeater>     
                        <webdiyer:AspNetPager ID="AspNetPagerNote" runat="server" OnPageChanged="AspNetPagerNote_PageChanged"
                            Width="90%" SubmitButtonText="到" ShowCustomInfoSection="Left" ShowBoxThreshold="3"
                            PageSize="16" AlwaysShow="True" HorizontalAlign="Right" Font-Size="X-Large"/> 
 </ContentTemplate>
 <Triggers>
   <asp:AsyncPostBackTrigger ControlID="btnExit2" EventName="Click" />
 </Triggers>
</asp:UpdatePanel>
... ...
<asp:Panel ID="pan" runat="server" style="display:none;">
 <table width="700" border="0" align="center">
  <tr>
    <td id="Drag">
       <table width="665" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align=right>
              <font color=white size="Large">文件夹:</font>
            </td>
            <td align=left>
                <asp:DropDownList ID="ddlFolder" Font-Size="Large" runat="server">
                </asp:DropDownList>
            </td>
          </tr>
          <tr>
            <td align=right>
              <h2><font color=white>便笺:</font></h2>
            </td>
            <td align=left>
                <asp:TextBox ID="txtNote" TextMode=MultiLine Font-Size="Large" Width=500 Height=400 runat="server"></asp:TextBox>
            </td>
          </tr>
       </table>
    </td>
  </tr>
  <tr>
     <td bgcolor=aqua align=Center>
        <asp:Label ID="lblNoteId1" text="" Visible=false runat=server />
        <asp:Button ID="btnSave" runat="server" Text="保 存" Font-Size="Large" OnClick="btnSave_Click" />
        <asp:Button ID="btnDelNote2" runat="server" Text="删 除" Font-Size="Large" OnClick="btnDelNote2_Click" />
        <asp:Button ID="btnExit" runat="server" Text="取 消" Font-Size="Large" />
     </td>
  </tr>
</table>
</asp:Panel>
<ajaxtoolkit:ModalPopupExtender ID="Modal" runat="server" TargetControlID="tmpButton"
    PopupControlID="pan" DropShadow="true" PopupDragHandleControlID="Drag"
    CancelControlID="btnExit" />
<asp:Button ID="tmpButton" runat="server" Style="display: none" />后台部分代码:
    protected void RepeaterNote_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
      OleDbConnection conn1 = new OleDbConnection(Conn.GetConnString("DbPath"));
      System.Data.OleDb.OleDbDataAdapter adpt1 = new System.Data.OleDb.OleDbDataAdapter();
      DataTable q = new DataTable();      if (e.CommandName == "shownote")
      {
        lblNoteId1.Text = (String)e.CommandArgument;
        CreateDDl();        adpt1 = new System.Data.OleDb.OleDbDataAdapter("select FolderId,Cont from notes where id=" + (String)e.CommandArgument, conn1);
        adpt1.Fill(q);
        if (q != null)
        {
          ddlFolder.SelectedValue = ((Int32)q.Rows[0]["FolderId"]).ToString();
          lblFolderId.Text = ((Int32)q.Rows[0]["FolderId"]).ToString();
          txtNote.Text = (string)q.Rows[0]["Cont"];
        }
        else
        {
          ddlFolder.SelectedIndex = 0;
        }
        btnDelNote2.Visible = true;
        Modal.Show();
      }
      conn1.Close();
    }    protected void CreateDDl()
    {
      OleDbConnection conn1 = new OleDbConnection(Conn.GetConnString("DbPath"));
      System.Data.OleDb.OleDbDataAdapter adpt1 = new System.Data.OleDb.OleDbDataAdapter("select id,FolderName from NoteFolders where [user]='" + app.user() + "' order by FolderName",conn1);
      DataTable q = new DataTable();
      adpt1.Fill(q);      ddlFolder.Items.Clear();
      if (q!=null && q.Rows.Count> 0)
      {
        foreach (DataRow r in q.Rows)
        {
          ddlFolder.Items.Add(new ListItem((string)r["FolderName"], ((Int32)r["id"]).ToString()));
        }
      }
      conn1.Close();
      ddlFolder.Items.Add(new ListItem("未存档的", "0"));
      ddlFolder.Items.Add(new ListItem("[添加文件夹]", "99999"));
    }

解决方案 »

  1.   

    把ModalPopupExtender中的CancelControlID="btnExit" 这句去掉
    ModalPopupExtender默认执行的是JS脚本,要想执行后台的CS代码
    必须把所有与JS有关的事件代码去掉
    ModalPopupExtender属性中只要设定TargetControlID,PopupControlID就足够了
    可以根据需要添加BackgroundCssClass,DropShadow等美观属性
    但CancelControlID这类事件属性不要加
      

  2.   

    谢谢zhlei616,
    但是把ModalPopupExtender中的CancelControlID="btnExit" 这句去掉 还是不行啊!
      

  3.   

    把ModalPopupExtender中的CancelControlID="btnExit" 这句去掉 好象可以诶,
    但是还得仔细调试一下!
      

  4.   

    新的代码:(后台代码不变)
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
                                              <asp:Repeater ID="RepeaterFolder" runat="server" OnItemCommand="RepeaterFolder_ItemCommand">
                                                <HeaderTemplate>
                                                  <table cellspacing="0" cellpadding="0" width="100%">
                                                </HeaderTemplate>
                                             
                                                <ItemTemplate>
                                                    <tr>
                                                       <td>                 
                                    <asp:LinkButton ID="btnFolderSelect" CommandName="folderselect" CommandArgument=<%# Eval("id") %> Font-Size="Large" Width="95%" runat="server"><%# app.GetLenString(Convert.ToString(DataBinder.Eval(Container.DataItem, "FolderName")), 10) %></asp:LinkButton>
                                                       </td>
                                                    </tr>
                                                </ItemTemplate>
                                             
                                                <FooterTemplate>
                                                  </table>
                                                </FooterTemplate>
                                              </asp:Repeater>
                            <webdiyer:AspNetPager ID="AspNetPagerFolder" runat="server" OnPageChanged="AspNetPagerFolder_PageChanged"
                            Width="90%" SubmitButtonText="到" ShowCustomInfoSection="Left" ShowBoxThreshold="3"
                            PageSize="16" AlwaysShow="True" HorizontalAlign="Right" Font-Size="X-Large" />
     </ContentTemplate>
     <Triggers>
       <asp:AsyncPostBackTrigger ControlID="btnExit2" EventName="Click" />
     </Triggers>
    </asp:UpdatePanel>
    ... ...
    <asp:Panel ID="pan" runat="server" style="display:none;">
     <table width="700" border="0" align="center">
      <tr>
        <td id="Drag">
           <table width="665" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align=right>
                  <font color=white size="Large">文件夹:</font>
                </td>
                <td align=left>
                    <asp:DropDownList ID="ddlFolder" Font-Size="Large" runat="server">
                    </asp:DropDownList>
                </td>
              </tr>
              <tr>
                <td align=right>
                  <h2><font color=white>便笺:</font></h2>
                </td>
                <td align=left>
                    <asp:TextBox ID="txtNote" TextMode=MultiLine Font-Size="Large" Width=500 Height=400 runat="server"></asp:TextBox>
                </td>
              </tr>
           </table>
        </td>
      </tr>
      <tr>
         <td bgcolor=aqua align=Center>
            <asp:Label ID="lblNoteId1" text="" Visible=false runat=server />
            <asp:Button ID="btnSave" runat="server" Text="保 存" Font-Size="Large" OnClick="btnSave_Click" />
            <asp:Button ID="btnDelNote2" runat="server" Text="删 除" Font-Size="Large" OnClick="btnDelNote2_Click" />
            <asp:Button ID="btnExit" runat="server" Text="取 消" OnClick="btnExit_Click" Font-Size="Large" />
         </td>
      </tr>
    </table>
    </asp:Panel>
    <ajaxtoolkit:ModalPopupExtender ID="Modal" runat="server" TargetControlID="tmpButton"
        PopupControlID="pan" DropShadow="true"/>
    <asp:Button ID="tmpButton" runat="server" Style="display: none" />
      

  5.   

    现在还是不行。
    一开始点击RepeaterNote中的一行,弹出的Panel中的textBox,DROPDOWNLIST不显示指定内容(为空)。 
    而在点击了RepeaterFolder中的一行后,再点击RepeaterNote中的一行,
    弹出的Panel中的textBox为空,DROPDOWNLIST倒是有内容了!
    (RepeaterNote的代码见1楼。)
      

  6.   


    不好意思,忘了说,问题在标题中! (顺便善意地嘲笑一下CSDN,标题也做得太隐蔽了吧!)
      

  7.   

    没有错误提示,就是弹出的Panel中的textBox,DROPDOWNLIST不显示指定内容(为空)? 
      

  8.   

    跟踪过代码了,pan中的txtNote.Text明明就是有内容的,可是不是为何就是不显示出来!
      

  9.   

    zhlei616和fuda_1985,可以得到你们的进一步帮助吗?
      

  10.   

    好累,下断点到
      if (e.CommandName == "shownote") 
          { 
            lblNoteId1.Text = (String)e.CommandArgument; 
            CreateDDl(); 
    看是否每次页面你能否进入该条语句
    个人觉得你那个地方怪怪的
      

  11.   


    每次都可以进入该语句。内容一直到 弹出窗口的前一条语句 都没有丢失,怀疑AJAX控件的问题,但又不知怎样修改。
    已经按zhlei616说的那样改了,却不完全有用。ddlFolder里有内容了,但SelectedValue没有定位到指定值,txtNote则根本就不显示内容!
      

  12.   

    可能有人不明白我的问题,当我点击RepeaterNote中的一行时,弹出一个POPUP PANEL,这个PANEL中有一个
    txtNode和一个ddlFolder,按理他们应该显示出从数据库抓出来的内容,但是现在现象如34楼所述。
      

  13.   

    34楼的 “ddlFolder里有内容了,但SelectedValue没有定位到指定值”应为:
    “ddlFolder里有内容了,但没有定位到指定值。一直跟踪到 弹出窗口的前一条语句 ddlFolder.SelectedValue都是正确的。”
      

  14.   

    楼上的,谢谢!愿闻其详!给点规范的.net代码嘛!
      

  15.   

    斑竹,最后更新是meiZiNick,meiZiNick 的发言哪里去了? 回复数44,怎么总共才41楼?
      

  16.   

    更新数据表后,在查询绑定前加一条 等待800毫秒的语句:
    System.Threading.Sleep(800);