मैं के लिए एक ही कार्रवाई विधि का उपयोग कर रहा हूँ Add
तथा Edit
। तो मुझे ब्रेडक्रंब का शीर्षक बदलने का मुद्दा है। जब हम संपादन करते हैं तो अब यह हमेशा एड्रेस पता दिखा रहा है। तो क्या यह बदलना संभव है Title
गतिशील। केवल परिवर्तन है पता पते में पैरामीटर मान होगा AddressID
। गतिशील रूप से शीर्षक कैसे बदलें?
[HttpGet]
[MvcSiteMapNode(Title = "Add Address", ParentKey = "Addresses", Key = "AddAddress")]
public ActionResult GetEditAddress(string AddressID)
{
उत्तर:
जवाब के लिए 0 № 1आपको एक कस्टम विशेषता बनाना होगा जो MvcSiteMapNode को विस्तारित करता है।
अपनी कस्टम विशेषता के भीतर, आपको शीर्षक को गतिशील रूप से बदलने के लिए तर्क के साथ आना होगा।
जवाब के लिए 3 № 2
The SiteMapTitle विशेषता शीर्षक गतिशील रूप से बदलने के लिए है ।
[SiteMapTitle("Headline")]
public ViewResult Show(int blogId) {
// Headline is a string property of blog
var blog = _repository.Find(blogId);
return View(blog);
}
या
[SiteMapTitle("SomeKey")]
public ViewResult Show(int blogId) {
ViewData["SomeKey"] = "This will be the title";
var blog = _repository.Find(blogId);
return View(blog);
}