View Single Post
  #1 (permalink)  
Old September 14th, 2011, 05:59 PM
zhshqzyc zhshqzyc is offline
Registered User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot convert type 'System.Web.UI.Page' to MasterPage'

In chapter 7, page 239.
I tried the code below in Visual Studio 2008
Code:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
publicpartialclass_Default : System.Web.UI.Page
{
protectedvoid Page_PreInit(object sender, EventArgs e)
{
Page.MasterPageFile = "~/MasterPage.master";
}
protectedvoid Page_Load(object sender, EventArgs e)
{
MasterPage mp = (MasterPage)Page.Master;
mpLabel.Text = Master.myValue;
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
TextBox1.Text = "";
}
}
But there is an error
Code:
Cannot convert type 'System.Web.UI.Page' to MasterPage'
Thanks for help.