I have a TextArea control on my content page that is inside the UpdatePanel:
<asp:UpdatePanel runat="server" ClientIDMode="Static" ID="upTaskDetailRight" UpdateMode="Conditional"> <ContentTemplate> <div style="width: 98%; padding-bottom: 10px;" class="brClear"> <div style="width: 98%; height: 120px;"> <textarea id="taskNotes" runat="server" class="taskNotes" style="width: 100%; height: 100%; scrollbar-base-color: #A0A0A0; scrollbar-base-color: #A0A0A0; scrollbar-3dlight-color: #A0A0A0; scrollbar-highlight-color: #A0A0A0; scrollbar-track-color: #EBEBEB; scrollbar-arrow-color: #FFFFFF; scrollbar-shadow-color: #A0A0A0; scrollbar-darkshadow-color: #A0A0A0;"></textarea> </div> </div> </ContentTemplate> </asp:UpdatePanel>
I have a button in my MasterPage that accesses the TextArea value from the content page and updates the SQL database:
<asp:Panel ID="Panel93" runat="server" CssClass="navInnerDivContentsTopSubTwo"> <asp:ImageButton ID="ibSave" ImageUrl="~/theImages/Save.png" runat="server" CssClass="navImages" OnClick="btnSave_Click" /> <br /> <asp:LinkButton ID="btnSave" runat="server" Text="Save" ClientIDMode="Static" OnClick="btnSave_Click" CssClass="linkOff" /> </asp:Panel>
Code for:
System.Web.UI.HtmlControls.HtmlTextArea lblTDNotes; lblTDNotes = (System.Web.UI.HtmlControls.HtmlTextArea)ContentMain.FindControl("taskNotes"); protected void btnSave_Click(object sender, EventArgs e) { string strSaveQuery = @"UPDATE HSI.RMMEMO SET MEMO = '" + lblTDNotes.Value + "' WHERE MEMOID = '" + hfMemoIDYT.Value + "'";
When the page loads, TextArea has some pre-populated data. If I make changes to the TextArea data (add or remove text) and click the SAVE button on the main page, lblTDNoted.Value
from strSaveQuery
uses the pre-populated data, not the updated record.
How to get an updated record from a text field?
source share