ASP.NET - 内容页面问题

时间:2009-08-13 19:46:40

标签: asp.net

我已将控件和装饰从一个内容页面复制到另一个内容页面,因为它们几乎相似。

但是发生了以下问题:

(1) Button events are not firing.

(2) One page is loaded multiple times.

(3) Some AJAX buttons are not visible.

任何人都可以告诉我为什么会这样吗?

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="StudentControlPanel.aspx.cs" Inherits="Student_StudentControlPanel" Title="Untitled Page" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#C00000" Text="Label"
        Width="318px"></asp:Label><br />
    <ext:button id="btnLogOut" runat="server" autopostback="True" onclick="btnLogOut_Click"
        text="Log Out"></ext:button>
    <table>
        <tr>
            <td style="width: 3px">
    <table>
        <tr>
            <td colspan="5">
                <strong><span>Student Control Panel</span></strong></td>
        </tr>
        <tr>
            <td align="right">
                Username :</td>
            <td colspan="2">
                <asp:Label ID="labUsername" runat="server" Text="Label"></asp:Label></td>
            <td colspan="1" align="right">
                Roll No. :</td>
            <td colspan="1">
                <asp:Label ID="labRollNo" runat="server" Text="Label"></asp:Label></td>
        </tr>
        <tr>
            <td align="right">
                Student Name :</td>
            <td colspan="2">
                <asp:Label ID="labName" runat="server" Text="Label"></asp:Label></td>
            <td colspan="1" align="right">
                Reg No. :</td>
            <td colspan="1">
                <asp:Label ID="labRegNo" runat="server" Text="Label"></asp:Label></td>
        </tr>
        <tr>
            <td align="right">
            </td>
            <td colspan="2">
            </td>
            <td colspan="1" align="right">
                Department :</td>
            <td colspan="1">
                <asp:Label ID="labDepartment" runat="server" Text="Label"></asp:Label></td>
        </tr>
        <tr>
            <td align="right">
            </td>
            <td colspan="2">
            </td>
            <td colspan="1">
            </td>
            <td colspan="1">
            </td>
        </tr>
        <tr>
            <td align="right" style="height: 21px">
            </td>
            <td colspan="2" style="height: 21px">
            </td>
            <td colspan="1" style="height: 21px">
            </td>
            <td colspan="1" style="height: 21px">
            </td>
        </tr>
    </table>
            </td>
            <td colspan="2" valign="top"><table>
                    <tr>
                        <td colspan="3">
                            <strong>Mails</strong></td>
                    </tr>
                    <tr>
                        <td colspan="3" style="text-align: center">
                            <asp:Button ID="btnMail" runat="server" Height="24px" Text="Send Mail" Width="82px" OnClick="btnMail_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3">
                            <asp:Button ID="btnOldMails" runat="server" Text="Old Mails" OnClick="btnOldMails_Click" /></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <br />
    &nbsp;<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="NoticeObjectDataSource" OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
        <Columns>
            <asp:CommandField HeaderText="View Notice" ShowSelectButton="True" />
            <asp:BoundField DataField="NoticeCode" HeaderText="NoticeCode" SortExpression="NoticeCode" />
            <asp:BoundField DataField="HangingDate" HeaderText="HangingDate" SortExpression="HangingDate" />
            <asp:BoundField DataField="TeacherCode" HeaderText="TeacherCode" SortExpression="TeacherCode" />
            <asp:BoundField DataField="TargetSessionCode" HeaderText="TargetSessionCode" SortExpression="TargetSessionCode" />
            <asp:BoundField DataField="CourseCode" HeaderText="CourseCode" SortExpression="CourseCode" />
            <asp:BoundField DataField="NoticeSubject" HeaderText="NoticeSubject" SortExpression="NoticeSubject" />
            <asp:BoundField DataField="NoticeContent" HeaderText="NoticeContent" SortExpression="NoticeContent" />
            <asp:BoundField DataField="ExpiryDate" HeaderText="ExpiryDate" SortExpression="ExpiryDate" />
            <asp:CheckBoxField DataField="IsExpired" HeaderText="IsExpired" SortExpression="IsExpired" />
        </Columns>
    </asp:GridView>
    <asp:ObjectDataSource 
        ID="NoticeObjectDataSource" 
        runat="server" 
        SelectMethod="GetNoticesBySessionCode"
        TypeName="Ice_Web_Portal.BO.Notice" OnSelecting="NoticeObjectDataSource_Selecting">
        <SelectParameters>
            <asp:Parameter Name="sessionCode" Type="String" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <br />
    <ext:scriptmanager id="ScriptManager1" runat="server" theme="Slate"></ext:scriptmanager>
</asp:Content>

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;
using System.Collections.Generic;



public partial class Student_StudentControlPanel : System.Web.UI.Page
{
    string sessionCode = string.Empty;
    string username = string.Empty;

    protected void Page_Load(object sender, EventArgs e)
    {
        username = (string)Request.QueryString["username"];

        Student std = Student.GetStudentByUsername(username);

        if (std != null)
        {
            labName.Text = std.StudentName;
            labUsername.Text = username;
            labRollNo.Text = std.RollNo;
            labRegNo.Text = std.RegNo;

            Dept dpt = std.Department;

            if (dpt != null)
            {
                labDepartment.Text = dpt.DeptName;
            }
            else
            {
                labDepartment.Text = "?";
            }

            sessionCode = std.SessionCode;
        }
    }

    protected void NoticeObjectDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        e.InputParameters["SessionCode"] = sessionCode;
    }

    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        int rowIndex = e.NewSelectedIndex;

        string noticeCode = GridView1.Rows[rowIndex].Cells[1].Text;
        string username = this.labUsername.Text;

        Server.Transfer(@"~/Student/ViewNoticeDetails.aspx?NoticeCode=" + noticeCode + "&username=" + username);
    }

    protected void btnMail_Click(object sender, EventArgs e)
    {
        try
        {
            Server.Transfer(@"~/Student/StudentSendMail.aspx?username=" + username);
            //Response.Redirect(@"~/Student/StudentSendMail.aspx?username=" + username);
        }
        catch (Exception ex)
        {
            string m;
        }
    }
    protected void btnOldMails_Click(object sender, EventArgs e)
    {
        try
        {
            Server.Transfer(@"~/Student/StudentOldMail.aspx?username=" + username);
            //Response.Redirect(@"~/Student/StudentSendMail.aspx?username=" + username);
        }
        catch (Exception ex)
        {
            string m;
        }
    }

    protected void btnLogOut_Click(object sender, EventArgs e)
    {
        AspNetUtil util = new AspNetUtil(this.Page);
        util.DisposeCookie("user");

        Server.Transfer("~/Default.aspx");
    }
}

1 个答案:

答案 0 :(得分:2)

如果您使用的是Visual Studio,则可能没有使用.designer.cs文件注册控件。检查以确保它们都在那里。