Hi,
Could do with a fresh pair of eyes please.
Have created the web forms NewPhotoAlbum and ManagePhotoAlbum in the root of the Site folder. The NewPhotoAlbum page appears to be working ok and creates a new entry for an album in the PhotoAlbum table.
However I get a 404 error (The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.) at the next line in the code behind of the NewPhotoAlbum page when it calls the ManagePhotoAlbum page.
Here is my code behind:
NewPhotoAlbum.aspx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class NewPhotoAlbum : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void DetailsView1_InsertItem()
{
PhotoAlbum photoAlbum = new PhotoAlbum();
TryUpdateModel(photoAlbum);
if (ModelState.IsValid)
{
using (var myEntities = new PlanetWroxEntities())
{
myEntities.PhotoAlbums.Add(photoAlbum);
myEntities.SaveChanges();
}
Response.Redirect(String.Format("ManagePhotoAlbum?PhotoAlbumId={0}", photoAlbum.Id.ToString()));
}
}
}
ManagePhotoAlbum.aspx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.ModelBinding;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ManagePhotoAlbum : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public IQueryable ListView1_GetData([QueryString("PhotoAlbumId")] int photoAlbumId)
{
var myEntities = new PlanetWroxEntities();
return from p in myEntities.Pictures
where p.PhotoAlbumId == photoAlbumId
select p;
}
public void ListView1_InsertItem([QueryString("PhotoAlbumId")] int photoAlbumId)
{
Picture picture = new Picture();
TryUpdateModel(picture);
if (ModelState.IsValid)
{
using (var myEntities = new PlanetWroxEntities())
{
picture.PhotoAlbumId = photoAlbumId;
myEntities.Pictures.Add(picture);
myEntities.SaveChanges();
}
}
}
public void ListView1_DeleteItem(int id)
{
}
}
I can't see any typos but to be honest I've been looking at this for so long I can't see the wood from the trees. Has anyone else had this issue?
Thanks in advance.
Harv