Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

updatepanel problem or possible bug

I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript __doPostBack(upEditReminder,id);

Then I set both Label and TextBox text to current DateTime.

protected void upReminder_Onload(object sender, EventArgs e)
{
    lbTest.Text = DateTime.Now.ToString();
    tbReminder.Text = DateTime.Now.ToString();

Problem is that Label is updated but TextBox date is updated only once when the page is loaded but not when __doPostBack(upEditReminder,id); is triggered. I cant figure out what the problem is.

I have also tried textarea runat="server" but still have the same problem.

Your help is much appreciated.

like image 383
Woland Avatar asked Feb 14 '26 18:02

Woland


1 Answers

This worked for me... is it different from what you're doing?

aspx code snippet:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="UpdatePanel">
    <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
    </ContentTemplate>
</asp:UpdatePanel>
<a href="#" onclick="__doPostBack('UpdatePanel1','');">Update</a>

codebehind snippet:

protected void UpdatePanel(object sender, EventArgs e)
{
    Label1.Text = DateTime.Now.ToString();
    TextBox1.Text = DateTime.Now.ToString();
}

Clicking the "Update" link triggers the UpdatePanel's postback which refreshes it via ajax and both the label and textarea get the updated timestamp.

like image 149
Rudism Avatar answered Feb 16 '26 07:02

Rudism



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!