My problem:
A master page with a contentplaceholder
A contentpage with a button and a updatepanel with a placeholder "PH" in it, which is loaded into the contentplaceholder in the master page.
A WebUserControl with a button and a label, which is loaded into the contentpage's "PH" when the contentpage button is clicked.
Clicking the button in the WebUserControl should then update the label with the correct datetime.now(), which do not happen on the first button click! But on all the rest, it works just fine... So, how can I make it work on the first button click?
My WebUserControl (ASPX file):
<asp:Panel runat="server" ID="tt">
<asp:Button Text="Update" runat="server" CssClass="btn" ID="btnUpdate"
onclick="btnUpdate_Click" />
<br />
<asp:Label runat="server" ID="lbl1">Lbl1 :</asp:Label>
<br />
<asp:Label runat="server" ID="lbl2">Lbl2: </asp:Label>
</asp:Panel>My WebUserControl (CodeBehind, C#) protected void Page_Load(object sender, EventArgs e)
{
lbl1.Text = "Loaded: " + DateTime.Now.ToLongTimeString();
[COLOR=Red]btnUpdate.Click += new EventHandler(btnUpdate_Click);[/COLOR]
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
lbl1.Text = "Button event: " + DateTime.Now.ToLongTimeString();
upBtn.Update();
lbl2.Text = "Updated";
}Suggestions are more than welcome! Should be fairly simple... (Yes, have google'd a lot, still am!) :)The function "btnUpdate_click" fires always, except on the first click, seems like the page needs to do a postback before it can use the function?
I've tried putting the "new Eventhandler" in everywhere, "Page_PreRender", "Page_Init"... Tried not having it...


Sign In
Create Account


Back to top









