I tried recreating your columns and update panel just to test it. I added a
"parent" update panel that holds everything except the Script Manager. And
then I dropped a variation of your code into my button onClick, which
created a Textbox control in the right column's Update Panel.
As expected, the partial post back worked fine. (with the "parent" Update
Panel). I would suggest, breaking through your user control; the two-click
bug might be in there.
I'm not sure what the code for your control looks like.
- Show quoted text -
Thanks for trying it !! ...i still can't figure out what's wrong. The
left side holds a menu with 3 items. 2 of them point to almost empty
user controls (with just a text heading), the other points to a user
control with a heading, a button and a textbox... the onclick of the
button has code to simply put the current date in the textbox. If I
click on that menu item first, it switches to that page and I can
click the button and it posts right away and displays the time... but
if i switch to another menu item and then come back to the one with
the textbox, it takes 2 clicks to get it to post correctly (when
debugging i can see it goes to the main form's Page_Onload and then to
the User Control's Page_Onload, but does not proceed to the
Button1_Click of the user control). Here's the code, maybe someone
sees the problem?
Main form table:
----------------------------
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Table ID="Table1" runat="server" Width="100%">
<asp:TableRow ID="TableRow1" runat="server">
<asp:TableCell ID="TableCell1" runat="server"
ColumnSpan="2"><center>
<asp:Label ID="Label1" runat="server" Text="Label"
CssClass="PageHeader">SIMS Admin Console</asp:Label></center></
asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="TableRow2" runat="server">
<asp:TableCell ID="TableCell2" runat="server" Width="20%">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Menu ID="Menu1" runat="server"
OnMenuItemClick="Menu1_MenuItemClick" >
<Items>
<asp:MenuItem Text="Load
Control1"></asp:MenuItem>
<asp:MenuItem Text="Load
Control2"></asp:MenuItem>
<asp:MenuItem Text="Load
Control3"></asp:MenuItem>
</Items>
</asp:Menu>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>
<asp:TableCell ID="TableCell3" runat="server">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
Main Form Code:
------------------------------
private const string BASE_PATH = "~/";
protected void Page_Load(object sender, EventArgs e)
{
LoadUserControl();
}
protected void Menu1_MenuItemClick(object sender,
MenuEventArgs e)
{
MenuItem menu = e.Item;
string controlPath = string.Empty;
switch (menu.Text)
{
case "Load Control2":
controlPath = BASE_PATH +
"WebUIClientSummary.ascx";
break;
case "Load Control3":
controlPath = BASE_PATH +
"WebUIConfigSummary.ascx";
break;
default:
controlPath = BASE_PATH + "WebUIMainSummary.ascx";
break;
}
LastLoadedControl = controlPath;
LoadUserControl();
}
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}
private void LoadUserControl()
{
string controlPath = LastLoadedControl;
if (!string.IsNullOrEmpty(controlPath))
{
UpdatePanel2.ContentTemplateContainer.Controls.Clear();
UserControl uc =
(UserControl)LoadControl(controlPath);
UpdatePanel2.ContentTemplateContainer.Controls.Add(uc);
}
}
User Control Source:
---------------------------------
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="WebUIClientSummary.ascx.cs"
Inherits="WebApplication1.WebUIClientSummary" %>
<p>
Client Summary</p>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
User Control Code:
-------------------------------
namespace WebApplication1
{
public partial class WebUIClientSummary :
System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
}
}
}