使用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>