-
March 14th, 2012, 10:46 PM
#1
ASP.NET MVC4 and Colorbox Plugin via Partial View
Hi,
Ive been trying to implement a colorbox popup for the past 2 days and Im at stuck at pretty much the last step.
I have an anchor that, when clicked, should load in a colorbox into a container I have set up in _Layout.cshtml
Code:
<a href="@Url.Action("RenderColorbox", "ContactPartial", new { path = "_ContactPartial" })" class="colorboxLink"><span>ContactUs</span></a>
Here is the js ajax request to load the partialview (_ContactPartial.cshtml) into its container in the _Layout.cshtml
Code:
$('.colorboxLink').click(function () {
$('.colorbox_container').load(this.href, function () {
var colorboxOptions = {
inline: true,
scrolling: false,
opacity: ".9",
fixed: true
}
$('#contactColorbox').colorbox(colorboxOptions);
});
return false; //return false for click event otherwise partial view will load on seperate page
});
Here is the partial view itself (_ContactPartial.cshtml)
Code:
@model DiscreteFX_MVC4.Models.ContactForm
<div id="contactColorbox">
@using (Html.BeginForm("Index", "ContactPartial", FormMethod.Post))
{
......
}
</div>
The partial view loads into its container correctly but is does not do so as a colorbox but rather as an un-animated popup modal. Can someone help me get the view to load as a colorbox.
Thanks
Last edited by techtalk7; March 15th, 2012 at 01:06 PM.
-
March 15th, 2012, 02:48 AM
#2
Re: ASP.NET MVC4 and Colorbox Plugin via Partial View
I posted and got my answer here for those having any similar issue:
http://stackoverflow.com/questions/9...-layour-cshtml
-
March 15th, 2012, 01:09 PM
#3
Re: ASP.NET MVC4 and Colorbox Plugin via Partial View
Hi, Im continuing my question on this thread because although I solved the first issue I had (and updated the code in my original post), Im now faced with a new issue (question also updated in original code)
Can somebody please help me achieve the effect so that it loads into a colorbox.
-
March 15th, 2012, 05:40 PM
#4
Re: ASP.NET MVC4 and Colorbox Plugin via Partial View
Originally Posted by techtalk7
I solved the first issue I had (and updated the code in my original post), Im now faced with a new issue (question also updated in original code)
Please do not do that. It causes allot of confusion if some one was out looking for a solution for you and returned to find a Different question..
Also There is no reason why you could not just ask your second question in either a new thread or as a new post in this thread like you did on Stackoverflow...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
March 15th, 2012, 06:28 PM
#5
Re: ASP.NET MVC4 and Colorbox Plugin via Partial View
My apologies, Ill keep those rules in mind.
Still unresolved and hoping someone familiar with colorbox plugin can take a look.
Thanks
-
March 16th, 2012, 06:18 PM
#6
Re: ASP.NET MVC4 and Colorbox Plugin via Partial View
Can anybody tell me why this isnt working Ive looked into it extensively for many many hours I just dont understand why it wont load as a colorbox
-
March 17th, 2012, 01:20 PM
#7
Re: ASP.NET MVC4 and Colorbox Plugin via Partial View
I dont know if this might give a clue but I just noticed that if I:
1) click colorboxLink, modal pops up
2) then click anywhere inside the modal, the following screenshot happen
.. the colorbox loads somewhere way down past the footer.
Its strange because I load the partial view (#contactColorbox) into the container (.colorboxContainer) before calling the colorbox on it and yet it loads into the footer and without any content..
Thanks again for taking a look.
Last edited by techtalk7; May 15th, 2012 at 01:09 AM.
-
June 9th, 2014, 02:18 AM
#8
Unable to retrive data from Mysql to MVC4
Hii All,
I complete beginner for .net and also to this site.
Please help me in dispalying my data in Mysql to MVC4.
ModelClass.cs
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.Web;
namespace Project4.Models
{
public class ModelClass
{
[Key]
public int topic_id { get; set; }
public int topic_number { get; set; }
public string subject { get; set; }
public string chapter { get; set; }
public string sub_chapter { get; set; }
public string lesson { get; set; }
public string topic { get; set; }
public string topic_code { get; set; }
public int tracking_number { get; set; }
public string IsActive { get; set; }
public string keywords { get; set; }
public class testdb : DbContext
{
public DbSet<ModelClass> ProjectClasses { get; set; }
}
}
}
I had created a ADO.net Entity Model
and added MySql table to it name it as testdb.
then I build the project
then create a controller that created all the CRUD operations
Error 2 'Project4.testdb' does not contain a definition for 'ProjectClasses' and no extension method 'ProjectClasses' accepting a first argument of type 'Project4.testdb' could be found (are you missing a using directive or an assembly reference?)
My Default1Controller.cs is showing error
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project4.Models;
using System.Data.SqlClient;
namespace Project4.Controllers
{
public class Default1Controller : Controller
{
private testdb db = new testdb();
//
// GET: /Default1/
public ActionResult Index()
{
return View(db.ProjectClasses.ToList());
}
//
// GET: /Default1/Details/5
public ActionResult Details(int id = 0)
{
ModelClass modelclass = db.ProjectClasses.Find(id);
if (modelclass == null)
{
return HttpNotFound();
}
return View(modelclass);
}
//
// GET: /Default1/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Default1/Create
[HttpPost]
public ActionResult Create(ModelClass modelclass)
{
if (ModelState.IsValid)
{
db.ProjectClasses.Add(modelclass);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(modelclass);
}
//
// GET: /Default1/Edit/5
public ActionResult Edit(int id = 0)
{
ModelClass modelclass = db.ProjectClasses.Find(id);
if (modelclass == null)
{
return HttpNotFound();
}
return View(modelclass);
}
//
// POST: /Default1/Edit/5
[HttpPost]
public ActionResult Edit(ModelClass modelclass)
{
if (ModelState.IsValid)
{
db.Entry(modelclass).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(modelclass);
}
//
// GET: /Default1/Delete/5
public ActionResult Delete(int id = 0)
{
ModelClass modelclass = db.ProjectClasses.Find(id);
if (modelclass == null)
{
return HttpNotFound();
}
return View(modelclass);
}
//
// POST: /Default1/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
ModelClass modelclass = db.ProjectClasses.Find(id);
db.ProjectClasses.Remove(modelclass);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
Plzzz guide me. Im struck in since 2 days.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|