Upgrade problem or possible error

I have TextBox(multi-line) and Labelin UpdatePanelwhich I update using javascript__doPostBack(upEditReminder,id);

I then set both the text Labeland TextBoxthe current DateTime.

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

The problem is that it is Labelupdated, but the TextBoxdate is updated only once, when the page loads, but not when it is fired __doPostBack(upEditReminder,id);. I can’t understand what the problem is.

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

Your help is greatly appreciated.

+3
source share
5 answers

It worked for me ... is it different from what you are 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();
}

"" UpdatePanel, ajax, .

+3

EnableViewState false ?

0

- ? , - ...

0

UpdatePanel. , , ?

, ClientID , :

__ doPostBack ( "ctrl00_ctrl01_upEditReminder", '');

0

, . , - postback updatepanel. .

, , javascript jQuery updatepanel reload. . , JavaScript/jQuery:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () { 
    var reminder = $("[id$='hidReminder']").val();
    $("[id$='tbReminder']").val(reminder);
});
0

Source: https://habr.com/ru/post/1737677/


All Articles