使用ascx目的就是为了提高某部分功能的重复利用,我简单通过源代码说一下对它的参数的输入和数出。
我们以省市区三级连动为例子。
vs2005下ascx页面的代码:
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <asp:DropDownList id="ddlProvince" runat="server" Width="100px" AutoPostBack="True" OnSelectedIndexChanged="ddlProvince_SelectedIndexChanged"> </asp:DropDownList> <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline"> <ContentTemplate> <asp:DropDownList id="ddlCity" runat="server" Width="100px" AutoPostBack="True" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged"> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlProvince" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server" RenderMode="Inline"> <ContentTemplate> <asp:DropDownList id="ddlDistrict" runat="server" Width="100px"> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlCity" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> </td> </tr> </table>