如何从内容页访问文本区域价值 [英] How to access the TextArea value from a content page

查看:88
本文介绍了如何从内容页访问文本区域价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的内容页的TextArea控件这是一个UpdatePanel内:

I have a TextArea control in my content page which is inside an 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>

我在我的母版按钮是从访问内容页的文本区域价值和更新SQL数据库:

I have a button in my MasterPage which is accessing the TextArea value from the content page and updating 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-背后:

Code-behind:

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  + "'";
    //MessageBox.Show(strSaveQuery);

    using (SqlConnection scConn = new SqlConnection(strMainConn))
    {
        try
        {
            scConn.Open();
            SqlCommand cmd = new SqlCommand(strSaveQuery, scConn);

            cmd.ExecuteNonQuery();

            Response.Redirect("YourTasks.aspx");
        }
        catch (Exception ce)
        {
        }
    }
}

在页面加载时,文本区域有一定的pre填充的数据。如果我做出了TextArea数据的任何更改(添加或删除文本),并在母版页击中SAVE按钮时, lblTDNoted.Value strSaveQuery 使用pre填充数据,而不是更新的条目。

When the page loads, the TextArea has some pre populated data. If I make any changes to the TextArea data (add or remove text) and hit the SAVE button in the Master page, the lblTDNoted.Value from the strSaveQuery is using the pre populated data and not the updated entry.

我如何从文本区域的更新的条目?

How do I get the updated entry from the textarea?

推荐答案

添加&LT;触发&GT; 你的的UpdatePanel

<asp:UpdatePanel runat="server" ...>
    <ContentTemplate>
        ...
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

这篇关于如何从内容页访问文本区域价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆