aspx页面后面的代码没有触发 [英] Code behind aspx page is not firing

查看:83
本文介绍了aspx页面后面的代码没有触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个水晶报告并附加到aspx页面上的按钮。但是根本没有调用按钮后面的代码。请帮忙。



axpx页面代码:



I have created a crystal report and attached to a button on aspx page. But code behind the button is not called at all. Please help.

axpx page Code:

<%@ Page Title="Department Average Competency Rating" Language="vb" AutoEventWireup="false" MasterPageFile="~/PageTemplate.master"

    CodeBehind="DepartmentAverageRating.aspx.vb" Inherits="PerformanceAppraisal.DepartmentAverageRating" %>

<%@ Register Src="Controls/EmployeeHeader.ascx" TagName="EmployeeHeader" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
  
        <tr id="ViewReport"  runat="server">
            <td colspan="2" align="center">
                <asp:Button ID="btnView" runat="server" CssClass="buttonStyle" Text="View Report" />
            </td>     
        
    </table>
    <br />
    <br />



***************** ************************************************** *****************************



页面后面的代码:


************************************************************************************************

Code behind the page:

Partial Public Class DepartmentAverageRating
    Inherits System.Web.UI.Page

    'Private _employee As Employee

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Session("AppraisalId") = -1
        If Not Page.IsPostBack Then
            'If (Security.UserRole <> UserRole.Manager Or Security.UserRole <> UserRole.Supervisor) AndAlso Not Utility.UserIsHr Then
            '    Response.Redirect("EmployeeSummary.aspx")
            'End If
            '_employee = New Employee(Security.CurrentEmployee)
            txtStartDate.Focus()
        End If
    End Sub

    Private Sub btnView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView.Click
        If Page.IsValid Then
            'Launch the report with the appropriate parameters.
            Dim strReportUrl As String

            strReportUrl = "ShowReport.ashx?Type=DepartmentAverageRating.rpt&StartDate=" & txtStartDate.Text & "&EndDate=" & txtEndDate.Text & "&Format=" & ddlReportFormat.SelectedValue

            ClientScript.RegisterClientScriptBlock(Me.GetType(), "OpenWin", _
                   "<script>window.open('" & strReportUrl & "')</script>", False)
        End If
    End Sub

End Class

推荐答案

在页面指令中为什么 AutoEventWireup =false

为了触发事件,它应该是 true



还定义aspx页面中按钮的OnClick事件。

Why AutoEventWireup="false" in the Page Directive?
It should be true in order to fire the Events.

Also define OnClick event for Button in aspx page.
<asp:Button ID="btnView" runat="server" CssClass="buttonStyle" Text="View Report" OnClick="btnView_Click" />



否则,该事件不会被解雇。


Otherwise, the event will not get fired.


这篇关于aspx页面后面的代码没有触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆