Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 15th, 2012, 09:59 AM
Authorized User
Points: 194, Level: 3
Points: 194, Level: 3 Points: 194, Level: 3 Points: 194, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2011
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default Something wron with local Server


I am testing inputin data in my database. The first I noticed is that most times when I run the website, I get a blank page that say Application_Offline.

Now the site loads fine, but when I try to insert data in the database using the DetailsView control, I keep getting the message: Internet Explorer cannot display te webpage.

Can anyone help me out please?

This is mostly happening with the Image.aspx page. Here is the code-behind for it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class Admin_Images : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        //if the page is not a post back, ensure that the GridView is 
        //displaying all images...
        //if (!Page.IsPostBack)
            int id = Convert.ToInt16(serviceDropDownList1.SelectedItem.Value);

            if (id == 0)
                //! The value of the first item in the dropdown list has been 
                //!set to 0; therefore, once this value is 0, it is certain that
                //!the selected item is not a valid Service. At this point, simply 
                //!display all images.
                GridView1.DataSourceID = "ServiceSqlDataSource";

        errorLabel.Visible = false;
    protected void serviceDropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        int id = Convert.ToInt16(serviceDropDownList1.SelectedItem.Value);
        if (id == 0)
            //GridView1.DataSourceID = "";
            GridView1.DataSourceID = "ServiceSqlDataSource";
            GridView1.DataSourceID = "SqlDataSource2";
    protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
       //Get the currently selected service
        int id = Convert.ToInt32(serviceDropDownList1.SelectedItem.Value);

        //if the selected item in the dropdown list is not a valid service
        if (id == 0)
            e.Cancel = true;
            errorLabel.Text = @"You cannot add an image when there is no service 
                                selected. Please select the service from the dropdown 
                                and then try again.";

            errorLabel.Visible = true;
            e.Values["ServiceID"] = id; //Set the ServiceID value in the database
            e.Values["DateAdded"] = DateTime.Now; //Set the DateAdded value in the database

            //Find the FileUpload control in the DetailsView
            FileUpload imageUpload = (FileUpload)DetailsView1.FindControl("FileUpload1");

            string virtualFolder = "~/ServiceImages/"; //set the virtual path of the folder
            string physicalFolder = Server.MapPath(virtualFolder); //set the physical server location
            string filename = Guid.NewGuid().ToString(); //generate a unique name for the file
            string extension = Path.GetExtension(imageUpload.FileName); //get the extension of the file

            //save the file to a physical server location
            imageUpload.SaveAs(Path.Combine(physicalFolder, filename + extension));

            //save the virtual url in the database
            e.Values["ImageUrl"] = string.Format("{0}{1}{2}", virtualFolder, filename, extension);




    protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        string deletedUrl = Server.MapPath(Convert.ToString(e.Values["ImageUrl"]));


Thank you...
Reply With Quote
  #2 (permalink)  
Old March 15th, 2012, 10:05 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi there,

Since this is not directly related to my book, may I suggest you post this in a general ASP.NET category from this list: http://p2p.wrox.com/asp-net-4-539/

This way, you'll attract more viewers and increase your chance on an answer.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Local vs. Server DB's Ascerbus BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 February 7th, 2009 06:04 AM
Local Server Startup Issue.. ankur_icfai SQL Server 2000 2 October 3rd, 2006 04:31 AM
Date Format - Local x Server fskilnik Classic ASP Basics 0 November 2nd, 2005 07:34 AM
Getting the a local copy of the Server DB Sappu SQL Server ASP 2 March 21st, 2005 12:27 PM

All times are GMT -4. The time now is 03:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.