ASP:UpdatePanel + Triggers virker ikke
Jeg har følgende kode:<strong>Publish to my network(s):</strong><br />
<asp:RadioButton ID="CreateSwapNetworkCustom" runat="server" ValidationGroup="ValidationGRPCreateSwap"
GroupName="CreateSwapNetworkRadio" Text="Custom" OnCheckedChanged="CreateSwapNetworkCustom_CheckedChanged"
AutoPostBack="true" />
<asp:RadioButton ID="CreateSwapNetworkAll" runat="server" ValidationGroup="ValidationGRPCreateSwap"
GroupName="CreateSwapNetworkRadio" Text="All" Checked="true" OnCheckedChanged="CreateSwapNetworkAll_CheckedChanged"
AutoPostBack="true" />
<asp:UpdatePanel ID="d" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CreateSwapNetworkCustom" EventName="CheckedChanged" />
<asp:AsyncPostBackTrigger ControlID="CreateSwapNetworkAll" EventName="CheckedChanged" />
</Triggers>
<ContentTemplate>
<asp:CheckBoxList ID="CreateSwapNetworkList" runat="server" Visible="false" ValidationGroup="ValidationGRPCreateSwap" />
</ContentTemplate>
</asp:UpdatePanel>
Code behind:
//Create swap - Custom network or All network
protected void CreateSwapNetworkCustom_CheckedChanged(object sender, EventArgs e)
{
if (CreateSwapNetworkCustom.Checked == true)
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM NetworkUserTBL WHERE UserID ='" + Session["UserID"] + "' AND Authed ='" + "1" + "'", con);
SqlDataReader PrintUserNetworks = cmd.ExecuteReader();
while (PrintUserNetworks.Read())
{
con2.Open();
SqlCommand cmd2 = new SqlCommand("SELECT * FROM NetworkTBL WHERE ID ='" + PrintUserNetworks["NetworkID"] + "'", con2);
SqlDataReader PrintNetworkInfo = cmd2.ExecuteReader();
PrintNetworkInfo.Read();
CreateSwapNetworkList.Items.Add(new ListItem(PrintNetworkInfo["Name"].ToString(), PrintNetworkInfo["ID"].ToString()));
PrintNetworkInfo.Dispose();
con2.Close();
}
PrintUserNetworks.Dispose();
con.Close();
CreateSwapNetworkList.Visible = true;
}
if (CreateSwapNetworkCustom.Checked == false)
{
CreateSwapNetworkList.Visible = false;
}
}
protected void CreateSwapNetworkAll_CheckedChanged(object sender, EventArgs e)
{
if (CreateSwapNetworkAll.Checked == true)
{
CreateSwapNetworkList.Visible = false;
}
if (CreateSwapNetworkAll.Checked == false)
{
CreateSwapNetworkList.Visible = true;
}
}
Mit problem er at de 2 radio buttons kun virker den ene vej. Dvs. at hvis jeg trykker på Custom, så kommer min checkdownlist, men hvis jeg klikker tilbage på All, så sker der intet.