tôi converted my project từ MVC 1 tới MVC 2 và Visual Studio 2008 mang lại cho tôi những lỗi sau:MvcHtmlString MVC 2 Chuyển đổi Lỗi
Error 1 'System.Web.Mvc.MvcHtmlString' does not contain a definition for 'Substring' and no extension method 'Substring' accepting a first argument of type 'System.Web.Mvc.MvcHtmlString' could be found (are you missing a using directive or an assembly reference?) C:\Dev\SapientFansite\SapientFansiteApplication\SapientFansiteWeb\Code\ExtensionMethods\Html.cs 68 75 SapientDevelopment.SapientFansite.Web
Đây là mã lỗi được trỏ đến. Nó đặc biệt gặp rắc rối với "linkHtml.Substring (0, 2)".
var linkHtml = htmlHelper.ActionLink(linkText, actionName, controllerName);
if (isActiveMenuItem) {
linkHtml = string.Format("{0} class=\"active\" {1}", linkHtml.Substring(0, 2), linkHtml.Substring(3));
}
return linkHtml;
}
Tôi nghi ngờ rằng nó có liên quan đến tham chiếu bị thiếu hoặc một số thứ nhưng tôi thua lỗ.
Cảm ơn bạn, điều này đã thực hiện thủ thuật. Có vẻ như ActionLink đã lôi kéo tôi một cách nhanh chóng. :) –