2014-05-16 58 views
1

我在我的應用程序中使用ajax工具箱評分控制。應用程序是在asp.net web表單中進行的。現在我需要更改Metro中的應用程序設計。我正在使用Metro UI CSS,並且在評級控制方面遇到問題。Metro UI CSS評分組件

與阿賈克斯我用這個代碼後面的代碼保存在數據庫率:

protected void Rating_Changed(object sender, RatingEventArgs e) 
{ 
int rowIndex = ((sender as Rating).NamingContainer as GridViewRow).RowIndex;  
int accommodationId = Convert.ToInt32(gvAccommodations.DataKeys[rowIndex].Value); 

     var context = new RezervacijaSmjestajaDbContext(); 
     var accommodation = 
       (
        from a in context.Accommodations.ToList() 
        where a.Id == accommodationId 
        select a 
       ) 
        .Single(); 

     accommodation.BrojOcjena++; 
     double NovaOcjena = Convert.ToDouble(e.Value); 
     accommodation.ZbrojOcjena = accommodation.ZbrojOcjena + NovaOcjena; 
     accommodation.Rating = accommodation.ZbrojOcjena/accommodation.BrojOcjena; 

     context.SaveChanges(); 
    } 

如何保存在數據庫率,如果我使用的Metro UI CSS等級控制?

回答

0

Metro UI rating widget具有onRate事件回調選項。

<div class="rating" data-role="rating" data-on-rate="func_onRate"></div> 

    function func_onRate(value, star, widget){ 
      // do your ajax here to save changed rating 
    }