<asp:Repeater ID="rpt_slider" runat="server" OnItemDataBound="rpt_slider_ItemDataBound">
<ItemTemplate>
<cc:HtmlEditor ID="Htmleditor1" runat="server" Height="300px" Width="550px" DialogButtonBarColor="Gray" DialogHeadingColor="Gray" DialogUnselectedTabColor="Gray" TabBackColor="Gray" Text='<%# Eval("banner_text")%>' DialogSelectedTabColor="Gray" EditorBorderColor="Gray" SelectedTabBackColor="Maroon" ToolbarColor="Silver" ToolstripBackgroundImage="Default" ButtonMouseOverColor="Gray" SelectedTabTextColor="WhiteSmoke" TabbarBackColor="Gainsboro" TabMouseOverColor="Gray" DialogSelectedTabTextColor="White" />
</ItemTemplate>
</asp:Repeater>
如何从Repeater获取html编辑器的文本...
此处Text='<%# Eval("banner_text")%>'
绑定在转发器上以及如何在我的c#代码上获取文本
答案 0 :(得分:2)
试试这个...我已经测试了你的工具..它有效..
添加using Winthusiasm.HtmlEditor;
,如下所示。
然后,您可以从服务器端访问您的编辑器。您可以使用以下方法从转发器中查找编辑器。
通过使用editor.Text
,您可以获得编辑的文本
如果您没有添加参考DLL,请将其添加到您的参考文献中。否则,当您放置using Winthusiasm.HtmlEditor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Winthusiasm.HtmlEditor;
namespace ListDrop
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (RepeaterItem item in Repeater1.Items)
{
if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item)
{
Editor editor= (Editor)item.FindControl("Editor1");
lblMessage.Text = editor.Text;
}
}
}
}
}
答案 1 :(得分:1)
我发现了我的污秽。
protected void btnUpdate2_click(object sender, EventArgs e)
{
try
{
Button ib = (Button)sender;
// string index = (ib.CommandName);
RepeaterItem gr = (RepeaterItem)ib.NamingContainer;
int index = gr.ItemIndex;
property.banner_type = "Primary";
property.active = Convert.ToBoolean(((CheckBox)rpt_slider.Items[index].FindControl("checkActive")).Checked);
property.banner_index = Convert.ToInt32(((DropDownList)rpt_slider.Items[index].FindControl("drop_IndexNo")).SelectedValue);
property.banner_id = Convert.ToInt32(ib.CommandArgument);
property.bottom_pos = Convert.ToInt32(((TextBox)rpt_slider.Items[index].FindControl("txtBPOS")).Text);
property.right_pos = Convert.ToInt32(((TextBox)rpt_slider.Items[index].FindControl("txtRPOS")).Text);
property.cr_user = Convert.ToInt32(Session["admin_id"]);
property.cr_date = Convert.ToDateTime(DateTime.Now.ToString());
property.banner_text = Convert.ToString(((HtmlEditor)rpt_slider.Items[index].FindControl("Htmleditor1")).Text);
property.tag = 2;
try
{
int result = 0;
result = balss.banner_insert(property.banner_id, property.banner_type, "", "", property.active, property.banner_index, property.cr_user, property.cr_date, property.banner_text, property.bottom_pos, property.right_pos, property.tag);
if (result > 0)
{
ClientScript.RegisterStartupScript(this.up1.GetType(), "Script", "<script type='text/javascript'>alert('Record Updated successfully.');</script>");
}
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(this.GetType(), "script", "<script text='text/javascript'> alert('" + ex.Message + "')</script>");
}
finally
{
}
getdata();
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "script", "<script type='text/javascript'>alert(' " + ex.Message + "');</script>", false);
}
finally
{
}
Response.Redirect("edit_banner");
}
on button submit click i am used
property.banner_text = Convert.ToString(((HtmlEditor)rpt_slider.Items[index].FindControl("Htmleditor1")).Text);
for get value of html editor for repeater.