Jesi523 0 Junior Poster in Training

I am trying to write an MVC application. I am rather new to MVC and I am taking the project over from someone else whom started writing it. This is what I am trying to do. I have some html documents that are located within my application. When a user clicks on a certain link a document opens in an iframe for display. My task controller tells the application which document to open depending on which link was clicked as the data is also stored in a sql database. So all that works fine. What I want the application to do is open that html document in an editor. I have the Telerik MVC controls but I cannot get it to work. Here is my code for my task:

public class Task
    {
        public int TaskID { get; set; }
        public string Title { get; set; }
        public string Status { get; set; }
        public string Url { get; set; }
        public string Notes { get; set; }

    }

    public class TaskDBContext : DbContext
    {
        public DbSet<Task> Tasks { get; set; }
    }

For my controller:

private TaskDBContext db = new TaskDBContext();

        //
        // GET: /Tasks/

        /*************start original
        public ViewResult Index()
        {
            return View(db.Tasks.ToList());
        }
        ***********************************end orig*/
        //[Authorize(Roles = @"IS Users")]
        public ViewResult Index(string sortOrder, string searchString)
        {
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "Name desc" : "";
            ViewBag.StatusSortParm = sortOrder == "Status" ? "Status desc" : "Status";
            var tasks = from t in db.Tasks
                        select t;

            if (!String.IsNullOrEmpty(searchString))
            {
                tasks = tasks.Where(t => t.Title.Contains(searchString));
            }

            switch (sortOrder)
            {
                case "Name desc":
                    tasks = tasks.OrderByDescending(t => t.Title);
                    break;
                case "Status desc":
                    tasks = tasks.OrderBy(t => t.Status);
                    break;
                default:
                    tasks = tasks.OrderBy(t => t.TaskID);
                    break;
            }
            return View(tasks.ToList());
        }

        //
        // GET: /Tasks/Details/5

        //[Authorize(Roles = @"IS Users")]
        public ViewResult Details(int id)
        {
            Task task = db.Tasks.Find(id);
            return View(task);
        }

        //
        // GET: /Tasks/Create

        //[Authorize(Roles = @"IS Users")]
        public ActionResult Create()
        {

            return View();
        } 

        //
        // POST: /Tasks/Create

        [HttpPost]
        //[Authorize(Roles = @"IS Users")]
        public ActionResult Create(Task task)
        {
            if (ModelState.IsValid)
            {
                db.Tasks.Add(task);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }

            return View(task);
        }

        //
        // GET: /Tasks/Edit/5

        //[Authorize(Roles = @"IS Users")]
        public ActionResult Edit(int id)
        {
            Task task = db.Tasks.Find(id);
            return View(task);
        }

        //
        // POST: /Tasks/Edit/5

        [HttpPost]
        //[Authorize(Roles = @"IS Users")]
        public ActionResult Edit(Task task)
        {
            if (ModelState.IsValid)
            {
                db.Entry(task).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(task);
        }

        //

        // GET: /Tasks/Delete/5
        //[Authorize(Roles = @"IS Users")]
        public ActionResult Delete(int id)
        {
            Task task = db.Tasks.Find(id);
            return View(task);
        }

        //
        // POST: /Tasks/Delete/5
       //[Authorize(Roles = @"IS Users")]
        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {            
            Task task = db.Tasks.Find(id);
            db.Tasks.Remove(task);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

       //[Authorize(Roles = @"IS Users")]
        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }

And for my view:

<iframe src="../../TaskHtml/@Html.DisplayFor(model => model.Url)" width="99%" height="500" frameborder="0">
                            </iframe>

I tried to change the view to this:
\

<iframe src="../../TaskHtml/@Html.EditorFor(model => model.Url)" width="99%" height="500" frameborder="0">
                                        </iframe>

along with trying several other thing, but it does not work.
Any help would be greatly appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.