Wednesday, May 23, 2012

asp.net mvc3,c#

I want separate friends facebook and twitter.
Like this :



Twitter Facebook



EditorTemplates: FriendModel.cshtml



@model App.Web.Models.FriendModel
<div>
<input type="checkbox" name="saveInputs" value="@Model.FriendID"/>
<img alt="" src="@Model.ProfileImageUrl" />
<strong>@Model.Name</strong> Friends: <strong>@Model.FriendsCount</strong>
</div>
<br />


Views: FriendTeam.cshtml



@model App.Web.Models.FriendTeamModel
@{
ViewBag.Title = "FriendTeam";
}
<h2>
FriendTeam</h2>

@using (@Html.BeginForm())
{ @Html.ValidationSummary(true)
<h3>Twitter</h3>
<br />
@Html.EditorFor(model => model.Friends.Where(x=>x.SocialNetworkName=="Twitter"))

<h3>Facebook</h3>
<br />
@Html.EditorFor(model => model.Friends.Where(x=>x.SocialNetworkName=="Facebook"))
}
<div>
@Html.ActionLink("Back to List", "Index")




FriendTeamModel:



   public class FriendTeamModel
{
public long FriendTeam{ get; set; }
public IEnumerable<FriendModel> Friends { get; set; }
}


FriendModel:



public class FriendModel
{
public string FriendID { get; set; }
public string SocialNetworkName { get; set; }

public string Name { get; set; }
public int FriendsCount { get; set; }
public string ProfileImageUrl { get; set; }
}


error :
Models can only be used with expressions access field of homeownership, the index of one-dimensional array or custom indexer single parameter.



Thanks,





No comments:

Post a Comment