富态文本框--小例 ---UMEditor

本文介绍了如何从UMEditor官网下载并部署.NET版本的编辑器,包括页面引用和后台图片上传处理代码的简单说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官网下载地址;http://ueditor.baidu.com/website/download.html

---官网下载下后.net 版 结构



1.页面引用:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="server">
<div id="tt" class="easyui-tabs" fit="true">
    <div title="商品详情">
    <table align="center" width="100%" border="0" class="datatable" cellspacing="1" cellpadding="0">
     <tr>
        <th style="width:70px">产品详情: <br /><a href="javascript:fnview()" style="color:Red">预览</a></th>
        <td style="position: relative;" colspan="4">
            <div id="txtContent"  style="min-height: 430px;max-height: 430px;" ></div>
        </td> 
        </tr>
    </table>
    <input  id="btn" type="button" value="提交" onclick="btnContent()"></input>
    </div> 
    
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="foot" runat="server">
 <link href="UMEditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet" />
<script src="UMEditor/umeditor.js" type="text/javascript"></script>
<script src="UMEditor/umeditor.config.js" type="text/javascript"></script>
<script src="UMEditor/lang/zh-cn/zh-cn.js" type="text/javascript"></script>
<script type="text/javascript">
    var ueoption = { toolbar: [
            'source | undo redo | emotion | bold italic underline strikethrough | forecolor backcolor | removeformat |',
            'link unlink | selectall cleardoc | paragraph fontfamily fontsize |',
            'justifyleft justifycenter justifyright justifyjustify |',
            'image insertvideo  | map |',
            'fullscreen'],
        autoClearinitialContent: false,
        wordCount: false,
        minFrameHeight: 80,
        maxFrameHeight: 80,
        elementPathEnabled: false,
        zIndex: 1,
        charset: "utf-8",
        initialStyle: 'p{font-size: 12px;line-height:15px; }'
    };
    var ue = UM.getEditor('txtContent', ueoption);
    function btnContent() {
        var txt = ue.getContent();
        alert(txt);
    }
</script>
</asp:Content>
2.umeditor.config.js 文件修改图片路径

3.imageUp.cs 文件 是上传图片后,后台代码,可配置保存图片地址,以及根据各自需求修改源码

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/html";

            //上传配置
            string pathbase = "upload/scpro/";                                                          //保存路径
            int size = 2;                     //文件大小限制,单位mb                                                                                   //文件大小限制,单位KB
            string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" };                    //文件允许格式

            string type = context.Request["type"];
            string editorId = context.Request["editorid"];

            //上传图片
            Hashtable info = new Hashtable();
            Uploader up = new Uploader();
            info = up.upFile(context, pathbase, filetype, size); //获取上传状态

            if (type == "ajax")
            {
                HttpContext.Current.Response.Write(info["url"]);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>parent.UM.getEditor('"+ editorId +"').getWidgetCallback('image')('" + info["url"] + "','" + info["state"] + "')</script>");//回调函数
                
            }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

4.也可以 页面定义时,加载上传地址和图片位置:如下



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值