我在我的应用程序中使用ajax工具包评级控件。应用程序在asp.net Web表单中进行。现在我需要在Metro中更改应用程序的设计。我正在使用Metro UI CSS,我在评级控制方面遇到了麻烦。
使用ajax我在代码中使用了这段代码来保存数据库中的速率:
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 :(得分: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
}