MohammadReza Roohafza

طبقه بندی موضوعی
نویسندگان

۲ مطلب با موضوع «C#-MVC» ثبت شده است

2Models in 1 View (Or multiple Models)

يكشنبه, ۱۰ بهمن ۱۳۹۵، ۱۰:۱۷ ق.ظ

Create a view model which exposes both these models as properties.

public class MusicStoreViewModel{ public IEnumerable<MvcMusicStore.Models.Album> Albums{get;set;} public IEnumerable<MvcMusicStore.Models.Posts> Posts{get;set;} } ... @model MusicStoreViewModel ... foreach(var album in model.Albums)... foreach(var post in model.Posts)...

  • محمد رضا روح افزا
با توجه به اینکه اکثر رخداد ها در MVC بصورت Html.ActionLink است .برای اخذ نظر موافق کاربر از تکه کد زیر استفاده می گردد

@Html.ActionLink("Delete",

    "DeleteTag", new { id = t.IDTag },

    new { onclick = "return confirm('آیا از حذف آیتم اطمینان دارید" + @t.Tag + "?')" })


  • محمد رضا روح افزا