我的一个页面中Page_Load事件不执行,调试不管肿么打断点都打不到。。    参考:
原本东西是.net4.0开发的  后来改成.net2.0  。 
原本都有这一行的,<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JL_WebObject.Default"  %>
后来报错我都给注释了不了解这是啥问题  求解答。

解决方案 »

  1.   

    贴代码<!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="../jquery-easyui/min/jquery-1.8.0.min.js"></script>
        <title></title>
        <style type="text/css">
            .tab_kid {
                height: 130px;
            }        .x-panel-foot-div {
                bottom: 0;
                font-style: normal;
                position: absolute;
                text-align: right;
                width: 100%;
            }        .spot_value {
                padding-left: 50px;
                padding-top: 50px;
                position: absolute;
                width: 100%;
                height: 100%;
                top: 1px;
                left: 55px;
                font-size: x-large;
                font-family: 微软雅黑;
            }
        </style>
        <script type="text/javascript">
            $(function () {
               
               
            })
        </script>
    </head><body>
        <div class="tab_kid">
            <label runat="server" id="values" class="spot_value"   ></label>
        </div>
        <div class="x-panel-foot-div">
            当前状态:<label runat="server" id="state">未检测到数据</label>
        </div>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    //using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;namespace JL_WebObject.real_time_data
    {
        public partial class RealValue : System.Web.UI.Page
        {        string checkname = "";
            protected void Page_Load(object sender, EventArgs e)
            {
                var name = Request.Params["name"];
                if (!IsPostBack)
                {
                    if (name != null)
                    {
                        //  Response.Write("hello");
                        string tempname = name.Replace('¥', '#');
                        checkname = tempname;
                        showvalue(checkname);
                    }
                }
            }
            private void showvalue(string name)
            {            DataManager manager = new DataManager();
                DataTable dt = new DataTable();
                dt = manager.GetSpots();
                string value = "";
                string unit = "";
                string type = "";
                string IsAlarmed = "";
                for (int a = 0; a < dt.Rows.Count; a++)
                {
                    if (dt.Rows[a]["name"].ToString() == name)
                    {
                        value = dt.Rows[a]["value"].ToString();
                        unit = dt.Rows[a]["unit"].ToString();
                        type = dt.Rows[a]["SpotType"].ToString();
                        IsAlarmed = dt.Rows[a]["IsAlarmed"].ToString();
                    }
                }
                if (value != "")
                {
                    if (value == "停止")
                    {
                        state.InnerText = "停止";
                    }
                    else
                    {
                        if (type == "Normal")
                        {
                            values.InnerHtml = value + "℃";
                            state.InnerText = "运行";
                        }
                        else if (type == "Switch")
                        {
                            values.InnerHtml = value;
                            state.InnerText = "运行";
                        }
                    }
                }
                else
                {
                    state.InnerText = "未检测到数据";
                }
            }    }
    }
      

  2.   

    原本这个页面只是个数据处理的页面,之前运行还是正常的,今天调试的时候突然发现没有显示数据了,一步步找下来就发现这个page_load不执行。。      纠结ING
      

  3.   

    设计器中的代码 page_load 的事件委托还在么?
      

  4.   

    designer.cs文件://------------------------------------------------------------------------------
    // <自动生成>
    //     此代码由工具生成。
    //
    //     对此文件的更改可能会导致不正确的行为,并且如果
    //     重新生成代码,这些更改将会丢失。 
    // </自动生成>
    //------------------------------------------------------------------------------namespace JL_WebObject.real_time_data {
        
        
        public partial class RealValue {
            
            /// <summary>
            /// values 控件。
            /// </summary>
            /// <res>
            /// 自动生成的字段。
            /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
            /// </res>
            protected global::System.Web.UI.HtmlControls.HtmlGenericControl values;
            
            /// <summary>
            /// state 控件。
            /// </summary>
            /// <res>
            /// 自动生成的字段。
            /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
            /// </res>
            protected global::System.Web.UI.HtmlControls.HtmlGenericControl state;
        }
    }
      

  5.   

    page指令部分的代码CodeBehind在 vs2005 中应该变成了codefile ,不能删掉指令
      

  6.   

     谢谢你的回复   
    我发现问题还是在于  项目出错时我去掉的这一行代码<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JL_WebObject.Default"  %>
      

  7.   

    我使用的是VS2012一样的,那个指令正是将aspx与cs文件关联的关键所在,并且AutoEventWireup="true"时才会触发cs中写的Page_Load
      

  8.   

    我使用的是VS2012一样的,那个指令正是将aspx与cs文件关联的关键所在,并且AutoEventWireup="true"时才会触发cs中写的Page_Load
    涨见识  3Q3Q