FCKEditor 不会在回发时设置 Value 属性!

发布于 2024-07-14 20:56:52 字数 8229 浏览 9 评论 0原文

我在我的 asp.net 网页上使用 FCKEditor 。 它看起来很漂亮,并且编辑器在前端看起来非常好。 唯一的问题是,回发时未设置 .Value 属性。 无论用户对页面上的控件的值进行什么更改,当我单击“提交”时,.Value 属性仍为空白。

我在 Google 上搜索了其他解决方案,其中大多数与 Ajax 存在冲突,例如 这个。 我的问题并没有通过这些解决方案得到解决; 它比这更基本。 我没有做任何与 Ajax 有关的事情; 我只是一个简单的 ASP.NET 新手,有一个简单的 Web 表单,并且 value 属性没有在回发时设置,在 IE 和 FF 中都没有。

看来至少还有另外一个人也遇到过这个问题,但是还没有解决。

有任何想法吗? 谢谢!


新的信息: 我在“hello world”测试网站上尝试了这一点 - 测试网站 100% 正常工作。 我的页面显然有问题,但我不知道从哪里开始追踪这个问题。

这是我的页面的标记,以防任何人都能看到我的新手眼睛看不到的明显内容:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="EmailTemplateEditForm.aspx.vb"
  Inherits="EEI_App.EmailTemplateEditForm" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>EEI - Email Template</title>
  <link rel="stylesheet" href="EEI.css">

  <script language="javascript" id="jssembleWare" src="sembleWare.js"></script>

  <style type="text/css">
    .style1
    {
      height: 251px;
    }
    .style2
    {
      width: 2%;
      height: 251px;
    }
    .style3
    {
      height: 490px;
    }
  </style>
</head>
<body>
  <form id="form1" runat="server">
  <%@ register src="header.ascx" tagname="header" tagprefix="uc1" %>
  <%@ register src="footer.ascx" tagname="footer" tagprefix="uc1" %>
  <uc1:header ID="header1" runat="server" />
  <!-- main content area -->
  <div class="content">
    <!-- title of the page -->
    <div class="boxheader">
      Email Template
    </div>
    <div class="standardbox">
      <!-- Start Page Main Contents-->
      <!-- error messages -->
      <div class="errorbox">
        <asp:Label ID="lblError" CssClass="ErrorControlStyle" runat="server" EnableViewState="False"
          Width="100%"></asp:Label>
      </div>
      <table class="contenttable">
        <tr>
          <td align="left" valign="top" class="style3">
            <div class="actionbox">
              <div class="navheadertitle">
                Navigation</div>
              <ul>
                <li>
                  <asp:LinkButton ID="btnSubmit" CssClass="LinkButtonStyle" runat="server">Submit</asp:LinkButton>
                </li>
                <li>
                  <asp:LinkButton ID="btnCancel" CssClass="LinkButtonStyle" runat="server" CausesValidation="false">Cancel</asp:LinkButton>
                </li>
              </ul>
            </div>
          </td>
          <td align="left" valign="top" class="style3">
            <p>
            </p>
            <table>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  <asp:Label ID="lblEmailTemplate_TemplateName" CssClass="LabelStyle" runat="server"
                    Width="175">Template Name</asp:Label>
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:TextBox ID="txtEmailTemplate_TemplateName" CssClass="TextBoxStyle" runat="server"
                    Width="100%"></asp:TextBox>
                </td>
                <td class="MCRSFieldLabelCell">
                  <asp:Label ID="lblEmailTemplate_TemplateType" CssClass="LabelStyle" runat="server"
                    Width="175">Template Type</asp:Label>
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:RadioButtonList ID="rblEmailTemplate_TemplateType" CssClass="RadioButtonListStyle"
                    runat="server" RepeatColumns="1" RepeatDirection="Horizontal" Width="135px">
                    <asp:ListItem Value="1">Cover Letter</asp:ListItem>
                    <asp:ListItem Value="2">Email</asp:ListItem>
                  </asp:RadioButtonList>
                </td>
                <td class="MCRSRowRightCell">
                  &nbsp;
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  Composition Date
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:Label ID="lblEmailTemplate_CompositionDate" CssClass="ElementLabelStyle" runat="server"
                    Width="175"></asp:Label>
                </td>
                <td class="MCRSFieldLabelCell">
                  Last Used Date
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:Label ID="lblEmailTemplate_LastUsedDate" CssClass="ElementLabelStyle" runat="server"
                    Width="175"></asp:Label>
                </td>
                <td class="MCRSRowRightCell">
                  &nbsp;
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  Composed By
                </td>
                <td class="MCRSFieldEditCell" colspan="3">
                  <asp:Label ID="lblPerson_FirstNames" CssClass="ElementLabelStyle" runat="server"></asp:Label>
                  <asp:Label ID="lblPerson_LastName" CssClass="ElementLabelStyle" runat="server"></asp:Label>
                </td>
                <td class="MCRSRowRightCell">
                  &nbsp;
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  <asp:Label ID="lblEmailTemplate_Subject" CssClass="LabelStyle" runat="server" Width="175">Subject</asp:Label>
                </td>
                <td class="MCRSFieldEditCell" colspan="3">
                  <asp:TextBox ID="txtEmailTemplate_Subject" CssClass="TextBoxStyle" runat="server"
                    Width="100%"></asp:TextBox>
                </td>
                <td class="MCRSRowRightCell">
                  &nbsp;
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="style1">
                  <asp:Label ID="lblEmailTemplate_Body" CssClass="LabelStyle" runat="server" Width="175">Body</asp:Label>
                </td>
                <td class="style1" colspan="3">
                  <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Height="500px">
                  </FCKeditorV2:FCKeditor>
                </td>
                <td class="style2">
                  &nbsp;
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </div>
    <p>
      <a class="InputButtonStyle" href="#_swTopOfPage">Top of Page</a>
    </p>
  </div>
  <uc1:footer ID="footer1" runat="server" />
  <p>
    <asp:TextBox ID="txtEmailTemplate_Body" CssClass="TextAreaStyle" Rows="4" runat="server"
      Width="100%" Height="16px" Visible="False"></asp:TextBox>
  </p>
  </form>
</body>
</html>

I'm using FCKEditor on my asp.net web page. It appears beautifully, and the editor looks really good on the front end. Only problem is, the .Value property is not being set on the postback. No matter what changes the user makes to the value of the control on the page, when I click "Submit", the .Value property remains blank.

I have Googled for other solutions, and most of them are of the variety where there's some conflict with Ajax, such as this and this. My problem is not solved by these solutions; it's much more fundamental than that. I'm not doing anything to do with Ajax; I'm just a simple asp.net newbie with a simple web form, and the value property is not being set on postback, not in IE and not in FF.

It appears that at least one other person has had this problem, but no solution yet.

Any ideas?
Thanks!


New information:
I tried this out on a "hello world" test web site - and the test web site works 100%. There is obviously a problem on my page, but I have no idea where to begin tracking this down.

Here's the markup of my page, in case anyone can see anything obvious that my newbie eyes can't:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="EmailTemplateEditForm.aspx.vb"
  Inherits="EEI_App.EmailTemplateEditForm" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>EEI - Email Template</title>
  <link rel="stylesheet" href="EEI.css">

  <script language="javascript" id="jssembleWare" src="sembleWare.js"></script>

  <style type="text/css">
    .style1
    {
      height: 251px;
    }
    .style2
    {
      width: 2%;
      height: 251px;
    }
    .style3
    {
      height: 490px;
    }
  </style>
</head>
<body>
  <form id="form1" runat="server">
  <%@ register src="header.ascx" tagname="header" tagprefix="uc1" %>
  <%@ register src="footer.ascx" tagname="footer" tagprefix="uc1" %>
  <uc1:header ID="header1" runat="server" />
  <!-- main content area -->
  <div class="content">
    <!-- title of the page -->
    <div class="boxheader">
      Email Template
    </div>
    <div class="standardbox">
      <!-- Start Page Main Contents-->
      <!-- error messages -->
      <div class="errorbox">
        <asp:Label ID="lblError" CssClass="ErrorControlStyle" runat="server" EnableViewState="False"
          Width="100%"></asp:Label>
      </div>
      <table class="contenttable">
        <tr>
          <td align="left" valign="top" class="style3">
            <div class="actionbox">
              <div class="navheadertitle">
                Navigation</div>
              <ul>
                <li>
                  <asp:LinkButton ID="btnSubmit" CssClass="LinkButtonStyle" runat="server">Submit</asp:LinkButton>
                </li>
                <li>
                  <asp:LinkButton ID="btnCancel" CssClass="LinkButtonStyle" runat="server" CausesValidation="false">Cancel</asp:LinkButton>
                </li>
              </ul>
            </div>
          </td>
          <td align="left" valign="top" class="style3">
            <p>
            </p>
            <table>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  <asp:Label ID="lblEmailTemplate_TemplateName" CssClass="LabelStyle" runat="server"
                    Width="175">Template Name</asp:Label>
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:TextBox ID="txtEmailTemplate_TemplateName" CssClass="TextBoxStyle" runat="server"
                    Width="100%"></asp:TextBox>
                </td>
                <td class="MCRSFieldLabelCell">
                  <asp:Label ID="lblEmailTemplate_TemplateType" CssClass="LabelStyle" runat="server"
                    Width="175">Template Type</asp:Label>
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:RadioButtonList ID="rblEmailTemplate_TemplateType" CssClass="RadioButtonListStyle"
                    runat="server" RepeatColumns="1" RepeatDirection="Horizontal" Width="135px">
                    <asp:ListItem Value="1">Cover Letter</asp:ListItem>
                    <asp:ListItem Value="2">Email</asp:ListItem>
                  </asp:RadioButtonList>
                </td>
                <td class="MCRSRowRightCell">
                   
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  Composition Date
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:Label ID="lblEmailTemplate_CompositionDate" CssClass="ElementLabelStyle" runat="server"
                    Width="175"></asp:Label>
                </td>
                <td class="MCRSFieldLabelCell">
                  Last Used Date
                </td>
                <td class="MCRSFieldEditCell">
                  <asp:Label ID="lblEmailTemplate_LastUsedDate" CssClass="ElementLabelStyle" runat="server"
                    Width="175"></asp:Label>
                </td>
                <td class="MCRSRowRightCell">
                   
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  Composed By
                </td>
                <td class="MCRSFieldEditCell" colspan="3">
                  <asp:Label ID="lblPerson_FirstNames" CssClass="ElementLabelStyle" runat="server"></asp:Label>
                  <asp:Label ID="lblPerson_LastName" CssClass="ElementLabelStyle" runat="server"></asp:Label>
                </td>
                <td class="MCRSRowRightCell">
                   
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="MCRSFieldLabelCell">
                  <asp:Label ID="lblEmailTemplate_Subject" CssClass="LabelStyle" runat="server" Width="175">Subject</asp:Label>
                </td>
                <td class="MCRSFieldEditCell" colspan="3">
                  <asp:TextBox ID="txtEmailTemplate_Subject" CssClass="TextBoxStyle" runat="server"
                    Width="100%"></asp:TextBox>
                </td>
                <td class="MCRSRowRightCell">
                   
                </td>
              </tr>
              <tr class="MCRSFieldRow">
                <td class="style1">
                  <asp:Label ID="lblEmailTemplate_Body" CssClass="LabelStyle" runat="server" Width="175">Body</asp:Label>
                </td>
                <td class="style1" colspan="3">
                  <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Height="500px">
                  </FCKeditorV2:FCKeditor>
                </td>
                <td class="style2">
                   
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </div>
    <p>
      <a class="InputButtonStyle" href="#_swTopOfPage">Top of Page</a>
    </p>
  </div>
  <uc1:footer ID="footer1" runat="server" />
  <p>
    <asp:TextBox ID="txtEmailTemplate_Body" CssClass="TextAreaStyle" Rows="4" runat="server"
      Width="100%" Height="16px" Visible="False"></asp:TextBox>
  </p>
  </form>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

吃不饱 2024-07-21 20:56:52

在 ASP.Net 上从 FCKeditor (FCKeditor.Value) 获取值时出现问题
1.如果不设置初始值FCKeditor.Value,没有问题,所有放入FCKeditor的值都可以通过FCKeditor.Value获取。
2.问题:如果初始值FCKeditor.Value不为空,那么如果我想要获取值,它只给我初始值。

我已经解决了!!!!
我花了一整天的时间……好不容易才找到答案。
特意注册来写回复!
看! 示例:

// 将初始值设置为 FCKeditor

void Page_Init(object sender, EventArgs e)
{
DataTable dT_01 = new DataTable();
      dT_01 = DataLayerMainContent.ArticlesSelect(2);
      FCKeditor_Edit.Value = dT_01.Rows[0]["ArticleText"].ToString();
}

注意!!!
你不必在这里这样做!

protected void Page_Load(object sender, EventArgs e)
{
    // Not here!!!
}

中获取值

protected void Btn_ContentEditedSave_Click(object sender, EventArgs e)
{
    //FCKeditor_Edit.Value
    // And add this value to DataBase
    DataLayerAdminPost.ContentMainEdit(1, FCKeditor_Edit.Value);
    Response.Redirect(Request.RawUrl);
}

// 并从 FCKeditor主要思想 !
在 Page_Init 处为 FCKeditor 设置初始值!

Problem with getting value from FCKeditor (FCKeditor.Value) at ASP.Net
1. If initial value FCKeditor.Value not set, there is no problem, all values, which are placed to FCKeditor can get with FCKeditor.Value.
2. Problem: if initial value FCKeditor.Value is not null, then if I want get value, it gives me only initial value.

I have solved!!!!
I spent the whole day ... Hardly found the answer.
Specially registered to write a reply!
Look! Example:

// Set initial value to FCKeditor

void Page_Init(object sender, EventArgs e)
{
DataTable dT_01 = new DataTable();
      dT_01 = DataLayerMainContent.ArticlesSelect(2);
      FCKeditor_Edit.Value = dT_01.Rows[0]["ArticleText"].ToString();
}

Attention!!!
You have not to do this here!!

protected void Page_Load(object sender, EventArgs e)
{
    // Not here!!!
}

// And get Value from FCKeditor

protected void Btn_ContentEditedSave_Click(object sender, EventArgs e)
{
    //FCKeditor_Edit.Value
    // And add this value to DataBase
    DataLayerAdminPost.ContentMainEdit(1, FCKeditor_Edit.Value);
    Response.Redirect(Request.RawUrl);
}

Main Idea!
Set initial value to FCKeditor at Page_Init!

水中月 2024-07-21 20:56:52

你启用了 ViewState 吗? ANS = Yes

编辑:好的,然后在 Page_Init 事件中尝试添加以下内容:

Page.RegisterRequiresPostBack(FCKeditor1);

Have you got ViewState enabled? ANS = Yes

EDIT: OK, then inside the Page_Init event try adding the following:

Page.RegisterRequiresPostBack(FCKeditor1);
月下客 2024-07-21 20:56:52

上面的解决方案对我不起作用,但是我找到了解决方案这里

这里是我使用的代码

protected void Page_Load(object sender, EventArgs e)
{
    ScriptManager.RegisterOnSubmitStatement(
        this, 
        this.GetType(), 
        "AjaxHack", "for ( var i = 0; i < parent.frames.length; ++i ) if ( parent.frames[i].FCK ) parent.frames[i].FCK.UpdateLinkedField();");
}

希望能拯救某人的一天。 我花了两个月的时间寻找解决方案。

干杯

The solution above didn't work for me, however i found solution here

Here's code what I used

protected void Page_Load(object sender, EventArgs e)
{
    ScriptManager.RegisterOnSubmitStatement(
        this, 
        this.GetType(), 
        "AjaxHack", "for ( var i = 0; i < parent.frames.length; ++i ) if ( parent.frames[i].FCK ) parent.frames[i].FCK.UpdateLinkedField();");
}

Hope that saves someones day. I was looking for the solution for 2 months.

Cheers

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文