2013-03-08 83 views
0

因此,我在運行MVC-4/Ext.Net 2.1應用程序時得到了一個小的aspx視圖。我想用代碼隱藏和設計器將它轉換爲「Web應用程序」。將C#MVC-4視圖轉換爲Web應用程序

當第一次單擊「轉換爲Web應用程序」中的視圖的上下文菜單中我得到了以下錯誤消息:

Unable to convert to Web Application because Code-Behind file is missing 

創建一個名爲「Default.aspx.cs」新類和引用之後從「Default.aspx的」爲代碼隱藏文件,我得到了以下錯誤消息:

Class 'System.Web.Mvc.ViewPage<dynamic>' not found in code-behind file 

我試圖直接使用「System.Web.Mvc」以及創建一個類,並在初始化它的一個實例:

public void Page_Load(object sender, EventArgs e) 
{ 
    ViewPage<dynamic> viewpage = new ViewPage<dynamic>(); 
    //Do Some Stuff 
} 

現在我問SO求助,因爲谷歌搜索並未帶來比「ext.net/download」或「msdn.microsoft.com/asp.net/」

回答

1

ASP.NET MVC "Convert to Web Application" option is missing in Visual Studio其他結果回答了這個問題相當好。按照所述的步驟進行後,轉換工作。

現在後面的代碼如下所示:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using Ext.Net; 
using Ext.Net.MVC; 
using Ext.Net.Utilities; 
using System.Web.Mvc; 

namespace MyNamespace.Views.Component 
{ 
    public partial class Default : ViewPage<dynamic> 
    { 
    //do the usual stuff 
    } 
} 

和Default.aspx的的@Page:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Base.Master" 
CodeBehind="~/Views/Component/Default.aspx.cs" Inherits="MyNamespace.Views.Component.Default" AutoEventWireup="True" %> 
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> 
相關問題