asp.net 控件无法抓取值或文本

本文关键字:文本 抓取 net 控件 asp | 更新日期: 2023-09-27 18:32:32

我的页面上有一个需要行="的cleEditor" cols=",当我做runat="Server"时 asp.net 不喜欢这样

为了解决这个问题,我试图使用FindControl,但我似乎无法以这种方式获取价值。

这是我的代码:

protected void os_submit_Click ( object sender, EventArgs e )
{
    Control cleEditor = FindControl( "editor2" );
    MailMessage mm = new MailMessage( "OnlineSignup@help.com", "help@help.com" );
    mm.Subject = "Online Signup Checklist";
    mm.Body = cleEditor.value; // Trying to grab the value of the textarea
    mm.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "127.0.0.1";
    smtp.Port = 25;
    smtp.Send( mm );
}

我有一个 id 为 editor2 的文本区域。 在场景背后,jquery将其变成了一个富文本编辑器。 我需要 asp.net 才能抓取此文本区域的值/文本。

谁能看出我做错了什么?

asp.net 控件无法抓取值或文本

不要把runat="server"放在 TextArea 上并执行以下操作:

protected void os_submit_Click ( object sender, EventArgs e )
{
    MailMessage mm = new MailMessage( "OnlineSignup@help.com", "help@help.com" );
    mm.Subject = "Online Signup Checklist";
    mm.Body = Request.Form["editor2"]; // Trying to grab the value of the textarea
    mm.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "127.0.0.1";
    smtp.Port = 25;
    smtp.Send( mm );
}