আমরা যখন নিয়ামক থেকে সম্পর্কিত ভিউতে ডেটা পাস করতে চাই তখন ডেটা দর্শন ব্যবহার করা হয়। দেখুন ডেটা খুব স্বল্প জীবন, এর অর্থ এটি পুনর্নির্দেশ ঘটে যখন তা ধ্বংস হয়ে যাবে। উদাহরণ (নিয়ন্ত্রক):
public ViewResult try1()
{
ViewData["DateTime"] = DateTime.Now;
ViewData["Name"] = "Mehta Hitanshi";
ViewData["Twitter"] = "@hitanshi";
ViewData["City"] = "surat";
return View();
}
try1.cshtm
<table>
<tr>
<th>Name</th>
<th>Twitter</th>
<th>Email</th>
<th>City</th>
<th>Mobile</th>
</tr>
<tr>
<td>@ViewData["Name"]</td>
<td>@ViewData["Twitter"]</td>
<td>@ViewData["City"]</td>
</tr>
</table>
টেম্পডাটা নিয়ন্ত্রণকারীদের মধ্যে বা ক্রিয়াগুলির মধ্যে ডেটা স্থানান্তর করে। এটি এক সময়ের বার্তাগুলি সঞ্চয় করতে ব্যবহৃত হয় এবং এর জীবনকাল খুব ছোট we
উদাহরণ (নিয়ন্ত্রক):
public ActionResult try3()
{
TempData["DateTime"] = DateTime.Now;
TempData["Name"] = "Ravina";
TempData["Twitter"] = "@silentRavina";
TempData["Email"] = "Ravina12@gmail.com";
TempData["City"] = "India";
TempData["MobNo"] = 9998975436;
return RedirectToAction("TempView1");
}
public ActionResult TempView1()
{
return View();
}
টেম্প ভিউ 1.সিএসটিএম
<table>
<tr>
<th>Name</th>
<th>Twitter</th>
<th>Email</th>
<th>City</th>
<th>Mobile</th>
</tr>
<tr>
<td>@TempData["Name"]</td>
<td>@TempData["Twitter"]</td>
<td>@TempData["Email"]</td>
<td>@TempData["City"]</td>
<td>@TempData["MobNo"]</td>
</tr>
</table>
TempDataএখানে স্ট্যাকওভারফ্লো.