关于写值的问题
cpp_1 2004-11-21 10:05:12 a.ascx
<asp:TextBox id="street" runat="server"></asp:TextBox>
<asp:TextBox id="city" runat="server"></asp:TextBox>
<asp:TextBox id="state" runat="server"></asp:TextBox>
<asp:TextBox id="zip" runat="server"></asp:TextBox>
---------------------------------------------
a.ascs.cs
public Hashtable bbb
{
get
{
Hashtable ctlhashtable=new Hashtable();
foreach(Control ctlcontrol in Controls)
{
if(ctlcontrol is TextBox)
{ctlhashtable.Add(((TextBox)ctlcontrol).ID,((TextBox)ctlcontrol).Text);}
}
return ctlhashtable;
}
set
{
Hashtable ctlhashtable=new Hashtable();
foreach(Control ctlcontrol in Controls)
{
if(ctlcontrol is TextBox)
{ctlhashtable.Add(((TextBox)ctlcontrol).ID,((TextBox)ctlcontrol).Text);}
}
}
}
================================================================
b.aspx
<%@ Register TagPrefix="uc1" TagName="addresshashtable" Src="a.ascx" %>
<uc1:addresshashtable id="Addresshashtable2" runat="server"></uc1:addresshashtable>
<asp:Label id="lbloutput" runat="server"></asp:Label>
<asp:Button id="Button1" runat="server" Text="submit"></asp:Button>
-------------------------------------------------------------
b.aspx.cs
protected addresshashtable Addresshashtable1=new addresshashtable();
private void Button1_Click(object sender, System.EventArgs e)
{
lbloutput.Text=Addresshashtable1.bbb["street"].ToString();
Addresshashtable1.bbb["zip"]="aaaaaaaa";
}
问题是,我可以用GET取到用户控件的值,但对用户控件写值就不行了
GET里有一个“return ctlhashtable”是不是在SET里面少了什么东西啊?