FCK上传图片问题解决

错误1The server didn't reply with a proper XML data. Please check your configuration

clip_image002

解决方案:

asp.net下的fckedito配置

用最简单的语言描述一下。其它配置和优化就不说了,只说怎么让它在asp.net环境下能用,能上传。

1、下载文件 http://www.fckeditor.net/download

这是目前最新的版本。 FCKeditor_2.6.5.zip fckeditor的页面文件 FCKeditor.Net_2.6.zip asp.net下的上传用的 dll控件和其源文件

2 解压FCKeditor_2.6.5.zip 到网站根目录下的 fckeditor中,解压FCKeditor.Net_2.6.zip 将其目录 FCKeditor.Net_2.6\bin\Release中的 FredCK.FCKeditorV2.dll 复制到 根目录的/bin/

3、打开/fckeditor/fckconfig.js 修改两行代码

var _FileBrowserLanguage = 'aspx' ;

var _QuickUploadLanguage = 'aspx' ;

把默认的asp语言改成aspx

错误2 :FCKeditor出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/config.aspx"错误的解决办法

clip_image004

解决办法:

打开editor/filemanager/connectors/aspx/config.ascx修改CheckAuthentication()方法,返回true

C# code

private bool CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...
//
//        return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );
//
// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the
// user logs in your system.

        return true;
}

随便看了一下config.ascx里的内容,发现如果想让对每个用户进行不同的配置,FCKeditor支持的更好了。

posted @ 2011-05-30 16:53 Sum_yang 阅读(181) 评论(1) 编辑

出现了这个问题 ,找了很久弄好,后来别人提供了一个链接

http://codeverity.com/timweaver/nhibernate-invalid-index-for-this-sqlparametercollection/ 

 

 Here's my mapping file: [I swear I'm switching to attributes first chance I get, but I learned the Xml mapping and time doesn't permit the change at this point]

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    schema="TestDB.dbo"    
    namespace="Domain.Foo"
    >
  <class name="Domain.Foo.ProfileP, Domain" table="ProfileP" lazy="false" >
    <id name="ID" column="ID" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>
    <property name="ProfileId" column="profileId" type="Int32" />
    <property name="PaymentId" column="paymentId"   type="Int32"  insert="false" update="false" />
    <property name="Status" column="status"    type="string" length="10" />
    <many-to-one name="PaymentS" class="Domain.Foo.Sub, Domain" column="paymentId" cascade="save-update" not-null="true"  />
  </class>
</hibernate-mapping>

 

The problem is the line in red. The PaymentID is the ID value of the PaymentS class in the Domain.Foo.Sub namespace. So, NHibernate already knew the ID value and was using it in the update/save queries. In effect it was declared twice in the mapping file: once explicitly and once implicitly via the many-to-one relationship. The fix was to add insert="false" and update="false" to the paymentId property.

I ended up purchasing the NHibernate in Action book via the early access program. So far I am pleased with the purchase. The book has shed light on a lot of pieces of information that were unclear to me. Getting concise and complete information on NHibernate seems to be a lot harder than I would have thought.

posted @ 2011-04-18 09:10 Sum_yang 阅读(75) 评论(1) 编辑

1、要进行跳转链接 

      @Html.ActionLink("Edit""Edit"new { id=item.ID }) 

       return RedirectToAction("Index");

 2、可通过以下方式进行数据实体的验证

       if (ModelState.IsValid)  

 3、如何给默认值

     public ActionResult ssss(int id=0)

 4、以下代码实现的是在clr中进行mapping的时候,找delete就找到deleteconfirmed     

[HttpPost, ActionName("Delete")] 

public ActionResult DeleteConfirmed(int id =0)

 5、验证实例如下

       [Required(ErrorMessage = "Title is required")]

    public string Title { getset; }

    [Required(ErrorMessage 
= "Date is required")]
    
public DateTime ReleaseDate { getset; }

    [Required(ErrorMessage 
= "Genre must be specified")]
    
public string Genre { getset; }

    [Required(ErrorMessage 
= "Price Required")]
    [Range(
1100, ErrorMessage = "Price must be between $1 and $100")]
    
public decimal Price { getset; }

    [StringLength(
5)]
    
public string Rating { getset; }} 

 

 

 [DataType(DataType.Date)] 
       
public DateTime ReleaseDate { get; set; }
       
       
[DataType(DataType.Currency)]  public decimal Price { get; set; } 

      [DisplayFormat(DataFormatString = "{0:d}")]

       public DateTime ReleaseDate { get; set; }


 

 

 

//*********************************************************************//

ASP.NET MVC Tip #46 — Don't use Delete Links because they create Security Holes. 

posted @ 2011-04-13 22:58 Sum_yang 阅读(16) 评论(0) 编辑

1、使用tryUpdatemodel 的方式

2、在model中加入 类似以下代码

     [DisplayName("First Name"), StringLength(50)]

   public string FirstName { getset; }
   [DisplayName(
"Middle Name"), StringLength(50)]
   
public string MiddleName { getset; }
   [DisplayName(
"Last Name"), StringLength(50), Required]
   
public string LastName { getset; }
   [DisplayName(
"Birth Date"), DataType(DataType.Date)]
   
public DateTime BirthDate { getset; }
   [DataType(DataType.EmailAddress), Required]
   
public string Email { getset; }
   
public string Phone { getset; }
   
public string Postcode { getset; }
   [DataType(DataType.MultilineText)]

   public string Notes { getset; }

 

 3、客户端验证

   需要在模板里面加入 :<% Html.EnableClientValidation(); %> 

 

 

 

 

posted @ 2011-04-10 05:59 Sum_yang 阅读(69) 评论(0) 编辑
1、记录用户访问人数

  首先定义一个用户访问类型 

 

public enum VisitorTypes {
  UnknownVisitor 
= 0,
  KnownVisitor 
= 1
}

 

   然后建立一个类

public class SiteVisitors {
  
private static SiteVisitors instance = new SiteVisitors();
  
private SiteVisitors() { }
  
public int UnknownVisitorCount { getprivate set; }
  
public int KnownVisitorCount { getprivate set; }
  
public static SiteVisitors Instance {
    
get {
          
return instance;
        }
  }

  //user arrives

  public void UnknownVisitorArrived() {
     SessionWrapper.SetUnknownType();
     UnknownVisitorCount
++;
  }
  
//known user arrives
  public void KnownVisitorArrives() {
     SessionWrapper.SetKnownType();
     KnownVisitorCount
++;
  }
  
//user logs in
  public void UnknownVisitorLoggedOn() {
     SessionWrapper.SetKnownType();
     UnknownVisitorCount
--;
     KnownVisitorCount
++;
  }
  
//user logs out
  public void KnownVisitorLoggedOut() {
     SessionWrapper.SetUnknownType();
     UnknownVisitorCount
++;
     KnownVisitorCount
--;
  }
  
//user session expires
  public void VisitorLeft() {
    
if (SessionWrapper.GetType() ==
       VisitorTypes.KnownVisitor)
       KnownVisitorLeft();
    
else
      UnknownVisitorLeft();
  }

 

} 

建立一个静态类 

public static class SessionWrapper {
  
private const string c_visitorType = "VisitorType";
  
public static void SetUnknownType() {
    HttpContext.Current.Session.Add(c_visitorType, 
      VisitorTypes.UnknownVisitor);
  }
  
public static void SetKnownType() {
    HttpContext.Current.Session.Add(c_visitorType, 
       VisitorTypes.KnownVisitor);
  }
  
public static new VisitorTypes GetType() {
    VisitorTypes result 
= VisitorTypes.UnknownVisitor;
    
if (HttpContext.Current.Session[c_visitorType] != null)
      result 
= (VisitorTypes)HttpContext.Current.Session 
        [c_visitorType];
    
return result;
  }
} 

使用:

protected void Session_Start() {

  if(Request.IsAuthenticated)
     SiteVisitors.Instance.KnownVisitorArrives();
  
else
     SiteVisitors.Instance.UnknownVisitorArrived();
}
protected void Session_End() {
     SiteVisitors.Instance.VisitorLeft();
}

 前台调用

<div id="logindisplay">

  <% Html.RenderPartial("LogOnUserControl"); %><br />
  Known visitor count: 
<%
    StateExamples.Models.SiteVisitors.Instance
      .KnownVisitorCount 
%> - Unknown visitor count: 
    
<%
    StateExamples.Models.SiteVisitors.Instance.UnknownVisitorCount 
     
%>
</div> 

 2、使用sessionwap记录访问信息

    public static class SessionWrapper {

  private const string c_account = "Account";
  
public static Account Account {
    
get { return GetObjectFromSession(c_account) as Account; }
    
set {
      
if (value == null)
         ClearItemFromSession(c_account);
      
else
         SetItemInSession(value, c_account);
    }
  }
  
private static string GetStringFromSession(string key) {
     
return GetObjectFromSession(key).ToString();
  }
  
private static int GetIntFromSession(string key) {
     
return (int)GetObjectFromSession(key);
  }
  
private static object GetObjectFromSession(string key) {
    
return HttpContext.Current.Session[key];
  }

 

 private static void SetItemInSession(object item, string key) { 
 HttpContext.Current.Session.Add(key, item);
  }
  private static void ClearItemFromSession(string key) {
     HttpContext.Current.Session.Remove(key);
  }

 

 

 在登录上使用 

    SessionWrapper.Account = new AccountService() .GetAccountByUsername(userName);

在前台使用 :

<div id="logindisplay">
  
<% Html.RenderPartial("LogOnUserControl"); %><br />
  
<%= StateExamples.Models.SessionWrapper.Account != null  
    
? "Welcome " +  
    StateExamples.Models.SessionWrapper.Account.Username 
+ " 
   from session wrapper!"  : "" %>

</div>  

 3、使用cache

   public class CacheWrapper

public class CacheWrapper {
  
private List<object> GetCacheItems(string[] keys) {
   IDictionaryEnumerator theCache 
= 
      HttpContext.Current.Cache.GetEnumerator();
   List
<object> results = new List<object>();
   
while (theCache.MoveNext()) {
     
if (keys.Contains(theCache.Key))
        results.Add(theCache.Value);
   }
    
return results;
  }

  private object GetCachItem(string key) { 

if (HttpContext.Current.Cache[key] != null)
      
return HttpContext.Current.Cache[key];
    
return null;
  }
  
private void AddCacheItems(Dictionary<stringobject> items) {
    
foreach (KeyValuePair<stringobject> item in items) {
       AddCacheItem(item.Key, item.Value);
    }
  }
  
private void AddCacheItem(string key, object item) {
   HttpContext.Current.Cache.Add(key, item, 
null//dependencies 
      DateTime.MaxValue, //absolute expiration 
      new TimeSpan(0100), //sliding expiration 
      CacheItemPriority.Default, //priority 
      null); //callback
  }
 public void PutProducts(List<Product> products) {
    Dictionary<string, object> itemsToCache = new 
       Dictionary<string, object>();
    foreach (Product product in products) {
       itemsToCache.Add(product.Name, product);
    }
    AddCacheItems(itemsToCache);
  }
  public List<Product> GetProducts(string[] productNames) {
     List<Product> results = new List<Product>();
     List<object> cacheItems = GetCacheItems(productNames);
     foreach (object cacheItem in cacheItems) {
        results.Add(cacheItem as Product);

     } 

 return results.OrderBy(p => p.Name).ToList();

  } 

 把产品预装

    private void PreLoadProductCatalog() {

  List<Product> products = new ProductService().GetProducts();
  
new CacheWrapper().PutProducts(products);

}

 

然后如何获取

 List<Product> products = new CacheWrapper().GetProducts(new[] {
     
"Name1""Name5""Name98""Name39""Name88""Name34"
  });

 return View(products);  

 

4、使用页面缓存

   在action 上加

    [OutputCache(Duration = (60 * 60), VaryByParam = "none")]  

 5、

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2011-04-09 05:47 Sum_yang 阅读(262) 评论(0) 编辑
摘要: 1、使用jquery实现日期选择 需要用到jquery jquery-ui-{vision}.js ui.all.css <scripttype="text/javascript">$(function(){$("input:text.date").datepicker({dateFormat:"MMd,yy"});});</script>阅读全文
posted @ 2011-04-04 05:53 Sum_yang 阅读(26) 评论(0) 编辑
摘要: 1、html helper <%:Html.TextBoxFor(model=>model.Title,...2、所见所得http://stackoverflow.com/questions/1559800/get-custom-attributes-from-lambda-property-expression#1560950.3、增加属性 <%:Html.TextBoxFor(model=>model.Title,new{disabled="true",alt="alttexthere"})%>-----不可用。有ALT阅读全文
posted @ 2011-04-03 07:29 Sum_yang 阅读(20) 评论(0) 编辑
摘要: 1、使用for 和foreach 2、控制checkbox3、控制radioButtons4、分页 通过在后台控制分页查询的内容来实现,oh....5、阅读全文
posted @ 2011-04-01 06:29 Sum_yang 阅读(22) 评论(0) 编辑
摘要: mvc前三章都是必须知道的(所以不用做备忘),被忽视的往往是小东西,但这些东西会左右思路,决定成败。1 如何创建和使用一个Master 在Master页面时设置 <asp:ContentPlaceHolderID="ContentPlaceHolder1"runat="server"></asp:ContentPlaceHolder> 然后再使用页面上 :<asp:ContentID="Content1"ContentPlaceHolderID="MainContent"runat=&阅读全文
posted @ 2011-04-01 06:06 Sum_yang 阅读(85) 评论(0) 编辑
摘要: 工具:一个在mvc框架好用的数据库控件http://www.castleproject.org/castle/projects.html.一个自动补全工具 nbuilderNBuilder.org/Download阅读全文
posted @ 2011-03-30 06:09 Sum_yang 阅读(46) 评论(0) 编辑