I have a textbox called txtNote. When I enter some text I click a save button and contents are written the database. I now want to clear the textbox value, so I had been using txtNote.text = “” but it no longer works as the save button is now part an update panel trigger.
E.g.
<asp:TextBox ID="txtNote" runat="server" CssClass="textarea full" Rows="4" TextMode="MultiLine"></asp:TextBox>
<asp:Button ValidationGroup="valgroup1" ID="btnNoteSave" runat="server" Text="Save"/>
</div>
</div>
<div style="width: 100%; float: left">
<asp:UpdatePanel ID="pnlNotes" runat="server">
<ContentTemplate>
<div id="content_container" style="margin-top: 85px">
<asp:Label ID="lblNotes" runat="server"></asp:Label>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnNoteSave" EventName="click" />
</Triggers>
</asp:UpdatePanel>
</div>
Code behind:
Protected Sub btnNoteSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNoteSave.Click
If txtNote.Text <> "" Then
Dim newnote As New note()
newnote.LoggedBy = Session("user_id")
newnote.Note = txtNote.Text
newnote.Create()
txtNote.Text = "" 'this is not working.
Dim note As New note()
lblNotes.Text = note.shownotes(Val(txtTicketID.Value))
End If
End Sub
I’m guessing it’s not working as it’s not able to do proper postback as an update panel is involved.
Any ideas how to get round this probably simple prob?
Thanks,
Just wrap the
TextBoxin its ownUpdatePanel. Make sure to either set theUpdateModetoAlways, or add theButtonto theTriggersof the newUpdatePanel