后台 <%@ WebHandler Language="C#" Class="detailSection" %>using System; using System.Web; using System.Web.Script.Serialization; using System.Configuration; using System.Data.SqlClient; using System.Data; using System.Collections.Generic; using System.Text.RegularExpressions; public class jsondataSection { public string cFunction; }public class detailSection : IHttpHandler { public List<jsondataSection> jsdatasection = new List<jsondataSection>();
public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/xml"; context.Response.Charset = "UTF-8"; string cid = context.Request["Cid"]; string sql = "select * from DeptInfo where cDeptId='"+cid+"'"; string _conn = ConnectionString.ZGBTHumanResource(); SqlDataReader sdr = DAL.SqlHelper.ExecuteReader(_conn, CommandType.Text, sql); while (sdr.Read()) { string a = sdr["cFunction"].ToString().Replace("\r\n", "<br>"); jd.cFunction = a; jsdatasection.Add(jd); } context.Response.Write(ToJson(jsdatasection.ToArray())); } public string ToJson(object o) { JavaScriptSerializer j = new JavaScriptSerializer(); return j.Serialize(o); }
public bool IsReusable { get { return false; } }} 前台jsfunction detail_Section(cid) { Ext.Ajax.request({ url: "BTSystemOA/btrlzy/ConfiguringManagement/SectionManagement/detailSection.ashx" , async: false , success: function(response, config) { var data = response.responseText; var a = data.substring(2, data.length - 2); / var b = a.split(","); var itemarry = new Array(); for (var i = 0; i < b.length; i++) { var c = b[i].split(":"); for (var j = 0; j < c.length; j++) { if (!j % 2 == 0) { var d = c[j].substring(1, c[j].length - 1); itemarry.push(d); } } } for (var k = 0; k < itemarry.length; k++) { Ext.getCmp('cFunction').setValue(itemarry[0]); } } , failure: function() { Ext.MessageBox.alert('请注意', '菜单加载出错,请稍后再试!'); } , method: "post" , params: { Cid: cid, t: Math.random() } });全部代码
{ xtype: "textarea", fieldLabel: "备注", name: "", anchor: "96.7%", height: 40}
textarea会自动换行
后台
<%@ WebHandler Language="C#" Class="detailSection" %>using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public class jsondataSection
{
public string cFunction;
}public class detailSection : IHttpHandler { public List<jsondataSection> jsdatasection = new List<jsondataSection>();
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/xml";
context.Response.Charset = "UTF-8";
string cid = context.Request["Cid"]; string sql = "select * from DeptInfo where cDeptId='"+cid+"'"; string _conn = ConnectionString.ZGBTHumanResource();
SqlDataReader sdr = DAL.SqlHelper.ExecuteReader(_conn, CommandType.Text, sql); while (sdr.Read())
{
string a = sdr["cFunction"].ToString().Replace("\r\n", "<br>");
jd.cFunction = a;
jsdatasection.Add(jd); }
context.Response.Write(ToJson(jsdatasection.ToArray()));
} public string ToJson(object o)
{
JavaScriptSerializer j = new JavaScriptSerializer();
return j.Serialize(o);
}
public bool IsReusable {
get {
return false;
}
}}
前台jsfunction detail_Section(cid) {
Ext.Ajax.request({
url: "BTSystemOA/btrlzy/ConfiguringManagement/SectionManagement/detailSection.ashx"
, async: false
, success: function(response, config) { var data = response.responseText; var a = data.substring(2, data.length - 2); /
var b = a.split(","); var itemarry = new Array();
for (var i = 0; i < b.length; i++) {
var c = b[i].split(":");
for (var j = 0; j < c.length; j++) {
if (!j % 2 == 0) { var d = c[j].substring(1, c[j].length - 1);
itemarry.push(d);
}
}
} for (var k = 0; k < itemarry.length; k++) {
Ext.getCmp('cFunction').setValue(itemarry[0]);
}
}
, failure: function() {
Ext.MessageBox.alert('请注意', '菜单加载出错,请稍后再试!');
}
, method: "post"
, params: { Cid: cid, t: Math.random() }
});全部代码
不替换就是图片那样,
用<br>替换就是 "\r\n" 变成 "\u003cbr\u003e2"
"\r\n"----->"\\n"