简体   繁体   English

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

[英]FCKEditor doesn't set Value property on postback!

I'm using FCKEditor on my asp.net web page. 我在asp.net网页上使用FCKEditor 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. 唯一的问题是,未在回发中设置.Value属性。 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. 无论用户对页面上控件的值进行什么更改,当我单击“提交”时,.Value属性都保持空白。

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 . 我已经用Google搜索了其他解决方案,其中大多数解决方案都是与Ajax发生冲突的各种解决方案,例如thisthis My problem is not solved by these solutions; 这些解决方案无法解决我的问题; it's much more fundamental than that. 比这更根本。 I'm not doing anything to do with Ajax; 我与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. 我只是一个具有简单Web表单的简单asp.net新手,并且没有在回发中设置value属性,不是在IE中也不在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%. 新信息:我在“ hello world”测试网站上进行了尝试-该测试网站可以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">
                  &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>

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. 从ASP.Net上的FCKeditor(FCKeditor.Value)获取值的问题。1.如果未设置初始值FCKeditor.Value,则没有问题,放置到FCKeditor的所有值都可以通过FCKeditor.Value获取。 2. Problem: if initial value FCKeditor.Value is not null, then if I want get value, it gives me only initial value. 2.问题:如果初始值FCKeditor.Value不为null,那么如果我要获取值,它仅给我初始值。

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 //将初始值设置为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 //从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! 在Page_Init上将初始值设置为FCKeditor!

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. 我一直在寻找解决方案2个月。

Cheers 干杯

Have you got ViewState enabled? 是否启用了ViewState? ANS = Yes ANS =是

EDIT: OK, then inside the Page_Init event try adding the following: 编辑:确定,然后在Page_Init事件内尝试添加以下内容:

Page.RegisterRequiresPostBack(FCKeditor1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM