Hi,
I want to pass this varible "diff" from controller to view (Razor)
TimeSpan diff = vacationRttDemand.EndDate - vacationRttDemand.BeginDate;
and after passing , i want do display it ino label or labelfor
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Suthish NairRank #92 · 22.8K reputationPosted Jul 11, 2016, 4:28 AM EDT
kalu singh raoRank #884 · 2.4K reputationPosted Jul 11, 2016, 4:53 AM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Jul 11, 2016, 4:56 AM EDT
in controller action method
public ActionResult Create()
{
ViewBag.diff = "30" ;
}
in view page
@Html.Label("Set from controller",(string)ViewBag.diff)
try it in above way
but in your case you need some type casting
Benmakhlouf Saad122 reputationPosted Jul 11, 2016, 4:59 AM EDT
Ravi PatelRank #439 · 5.7K reputationPosted Jul 11, 2016, 5:12 AM EDT
Benmakhlouf Saad122 reputationPosted Jul 11, 2016, 6:10 AM EDT