主题: ASP.NET 中最简单调用并取值实现方法共享...(这个绝对可以 呵呵)
作者: OA系统架构师, 发布日期: 2009-12-15 13:20:49, 浏览数: 4210

看看下面有位同志以这个标题发的代码,但有点漏洞,正好有时间给大家做一个简单的Demo
客户端ASPX代码
<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="AddNewInfo.aspx.cs" Inherits="CmsProject.Page.AddNewInfo" %>

<!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>
    <script type="text/javascript" language="javascript" src="../JS/KindEditor/kindeditor.js"></script>
    <script>
         var txtInfoContextId = '<%=txtInfoContext.ClientID%>';//这里获得客户端ID
            KE.init({
                id : txtInfoContextId,
                cssPath : '../Css/Main.css'
            });
         
            KE.event.ready(function(){
                KE.create(txtInfoContextId);
                //IE下回车时生成<br />
               
                KE.util.pToBr(txtInfoContextId);
                /* 统计字数
                //可视化模式下输入文字时
                KE.event.input(KE.g[txtInfoContextId].iframeDoc, function(){
                    KE.$('word_count').innerHTML = KE.util.getPureData(txtInfoContextId).length;
                });
                //代码模式下输入文字时
                KE.event.input(KE.g[txtInfoContextId].newTextarea, function(){
                    KE.$('word_count').innerHTML = KE.util.getPureData(txtInfoContextId).length;
                });
                */
            });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="showText"  runat="server"></div>
    <div class="editor">
        <asp:TextBox TextMode="MultiLine" ID="txtInfoContext" Columns="100" Rows="20" runat="server"></asp:TextBox>
    </div>
        <%--您当前输入了 <span id="word_count">0</span> 个文字。<br/>--%>
    <asp:Button runat="server" ID="btnSubmit" Text="提交" onclick="btnSubmit_Click" />
    </form>
</body>
</html>

ASPX.CS的代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace CmsProject.Page
{
    public partial class AddNewInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            this.showText.InnerHtml = this.txtInfoContext.Text;
        }
    }
}


发表新帖 发表回复