freetextbox使用问题 我在addnews.aspx.cs文件中无法引用addnews.aspx中定义好的FreeTextBox1控件的ID怎么回事呀?基本情况:我在addnews.aspx页面中放了一个ID名称为“FreeTextBox1”的文本编辑器控件,然后我想在后台保存它的内容,代码是: string strcontent = Server.HtmlEncode(this.FreeTextBox1.Text);  测试运行时提示:“addnews.aspx并不包含FreeTextBox1的定义。” 
我的FreeTextBox配置应该没有问题的。之前我在另一个页面freetextbox_text.aspx也拖了一个FreeTextBox控件过去,不过在后参的CS代码里面没有写什么代码,freetextbox_text.aspx页面运行没有问题。但是我测试addnews.aspx页面时就不行,系统提示,addnews.aspx并不包含FreeTextBox1的定义。请高手帮忙解决!谢谢

解决方案 »

  1.   

    你要是做个用户控件,应该拖哪儿都没问题的。估计还是在配置上,前面的配置可能针对你的freetextbox_text.aspx。
      

  2.   

    addnew.aspx  源代码
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="addnews.aspx.cs" Inherits="manage_addnews"  ValidateRequest="false" %><%@ Register Assembly="FreeTextBox" Namespace="FreeTextBoxControls" TagPrefix="FTB" %><!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>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            增加新闻<br />
            <table border="0" cellpadding="2" cellspacing="2" style="width: 812px; height: 216px">
                <tr>
                    <td align="right" style="width: 97px">
                        新闻标题:</td>
                    <td style="width: 102px">
                        <asp:TextBox ID="txtNewsTitle" runat="server" Width="231px"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="right" style="width: 97px">
                        新闻内容:</td>
                    <td style="width: 102px">
                        &nbsp;<br />
                        &nbsp;<FTB:FreeTextBox ID="FreeTextBox1" runat="server" ImageGalleryPath="~/images/upload"
                            SupportFolder="/FreeTextBox/">
                        </FTB:FreeTextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 97px">
                        新闻图片:</td>
                    <td style="width: 102px">
                    </td>
                </tr>
                <tr>
                    <td align="right" style="width: 97px; height: 28px">
                        作者:</td>
                    <td style="width: 102px; height: 28px">
                        <asp:TextBox ID="txtAuthor" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td style="width: 97px; height: 47px" align="right">
                    </td>
                    <td style="width: 102px; height: 47px">
                        <table border="0">
                            <tr>
                                <td style="width: 100px">
                                    <asp:Button ID="Button1" runat="server" Text="添加" Width="58px" OnClick="Button1_Click" /></td>
                                <td style="width: 100px">
                                    <asp:Button ID="Button2" runat="server" Text="重置" Width="55px" /></td>
                            </tr>
                        </table>
                        &nbsp; &nbsp; &nbsp;&nbsp;</td>
                </tr>
                
                
                 <tr>
                    <td align="right" style="width: 97px; height: 28px">
                        </td>
                    <td style="width: 102px; height: 28px">
                        &nbsp;<br />
                        <br />
                        </td>
                </tr>
            </table>
        
        </div>
        </form>
    </body>
    </html>
      

  3.   


    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    public partial class manage_addnews : System.Web.UI.Page
    {
        dbClass CC = new dbClass();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] == null)
                Response.Write("<script>top.location.href='login.aspx';</script>");    
            else
            {
                //其他操作 
            }     }
        protected void Button1_Click(object sender, EventArgs e)
        {
            
            //调用dbClass类的ExecSQL方法,将填写的新闻信息添加到数据库中
           string strcontent = Server.HtmlEncode(this.FreeTextBox1.Text);  //提出出错的地方在这里!!
           
            CC.ExecSQL("INSERT INTO news_info( title,Content,auth,Dtime)VALUES ('" + this.txtNewsTitle.Text.Trim() + "', '" +strcontent+ "', '" + this.txtAuthor.Text.Trim() + "', '" + DateTime.Now.ToString() + "')");
           //调用dbClass类的MessageBox方法,弹出提示框,提示用户添加成功
            Response.Write(CC.MessageBox("添加成功!"));
            Response.Redirect("newslist.aspx");
        }  
    }
      

  4.   

    FreeTextBox是别人写好的文本编辑控件,提示“addnews.aspx并不包含FreeTextBox1的定义。“可是在前台页定义了这个控件的呀,他的ID号就是FreeTextBox1,无法引用,很是奇怪。呵呵