子页面左侧有一个搜框,因为多个页面调用,所以我给做成了一个用户控件left.ascx,left.ascx里面有一个动态的DropDownList里面选择新闻的种类,下面一个TextBox是输入关键字的。 因为search.aspx里面也包含left.ascx,而search.aspx右侧是一个GridView用来显示搜索的结果。问题是:搜索时总是提示型“DropDownList”的控件“Left1_ddl1”必须放在具有 runat=server 的窗体标记内我给left.ascx页面中加入<form ID="form2" runat="server">**</form则提示:
一页只能有一个服务器端 Form 标记。我认为left.ascx嵌套在search.aspx页面中应该是共用一个<form id="form1" runat="server">了。可为什么还提示
“DropDownList”的控件“Left1_ddl1”必须放在具有 runat=server 的窗体标记内呢??急求多谢了

解决方案 »

  1.   

    这是left.ascx的页面
    <form ID="form2" runat="server">
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQLCONNECTIONSTRING %>"
                        SelectCommand="SELECT [kindID], [kindName], [parentID] FROM [tb_newsKind] WHERE ([parentID] = 0)">
                        <SelectParameters>
                            <asp:Parameter DefaultValue="0" Name="parentID" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <table width="195" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td width="64" height="30"><div align="center" class="c">按类别</div></td>
                        <td width="131" height="30"><div align="center">
                            <asp:DropDownList ID="ddl1" runat="server" DataSourceID="SqlDataSource1"
                                DataTextField="kindName" DataValueField="kindID">
                            </asp:DropDownList></div></td>
                      </tr>
                      <tr>
                        <td height="30"><div align="center" class="c">关键字</div></td>
                        <td height="30"><div align="center">
                            <label>
                                &nbsp;<asp:TextBox ID="Searchkey" runat="server" Width="90px"></asp:TextBox></label></div></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="2"><div align="center">
                            <asp:Button ID="SButton" runat="server" Text="查询" OnClick="SButton_Click" />
                            <input type="submit" name="Submit2" value="重置" />
                        </div></td>
                      </tr>
                    </table>
                </form>