following code in details.cshtml page:
@{ @html.raw(" | "); (int = 0; < model.payments.count; i++) { @html.raw("<a href=../../payment/details/" + model.id + "/" + model.payments.elementat(i).accountid + ">" + model.payments.elementat(i).account.landioc + "</a>"); @html.raw(" | "); } } model.payments.elementat(i).account null reason, although payment has 1 account , include account in our linq expression (paymentcontroller):
_erasdb.payments.include("account").include("event").where(...) we have no idea why account null. complete code, see:
multiple calls elementat pretty inefficient. switch foreach - should fix elementat returning null, more efficient, , simpler.
also, why not just:
<text> | </text> foreach(var payment in model.payments) { <a href=../../payment/details/@model.id/@payment.accountid">@payment.account.landioc</a> <text> | </text> } if using lots of @html.raw(...), you're missing trick... in particular, stand chance of opening xss holes if use .raw.
Comments
Post a Comment