I am using an ASP.NET AJAX-Enabled Web application (ASP.NET 2.0 and AJAX Toolkit 1.0) that contains one button and 2 UpdatePanels (UpdatePanel_1 and UpdatePanel_2)
The button is registered with RegisterAsyncPostBackControl in the ScriptManager object UpdatePanel_1 is in "Conditional" update mode and contains a TextBox.
UpdatePanel_2 is in "Always" update mode and contains another TextBox
When the button is pressed its handler calls UpdatePanel_1.Update() that updates the value of the TextBox based on a randomly selected value in a list; Also the UpdatePanel_2's TextBox is being updated automatically , also without page refresh
Based on the value of a boolean ViewState variable I would also like to hide/show the UpdatePanels alternatively but I get the error :
"Sys.InvalidOperationException: COuld not find UpdatePanel with ID 'UpdatePanel_2' (or UpdatePanel_1).
If it is being updated dinamically then it must be inside another UpdatePanel"
How can it be done without adding extra wrapping UpdatePanels?
Thanks,
arunganu
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager1.RegisterAsyncPostBackControl(Button1);
if (!IsPostBack)
{
Visibility = true;
}
UpdatePanel_1.Visible = !Visibility;
UpdatePanel_2.Visible = Visibility;
Visibility = !Visibility;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Panel1.Visible)
UpdatePanel_1.Update();
}
protected bool Visibility
{
get
{
return (bool)(ViewState["Visibility"] ?? true);
}
set
{
ViewState["Visibility"] = value;
}
}