当我从Visual Studio 2012运行一个项目时,我正在使用的asp:button可以正常工作。但是,当我将项目发布到 IIS 6.1 时,按钮的单击事件处理程序未被调用。我已将Visual Studio附加到服务器上正在运行的进程,并确认回发正在触发,但从未调用单击处理程序。
下面是我的 web.config 以及页面和代码隐藏。
默认.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="BIR_Injuries._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="Stylesheet" type="text/css" href="Styles/main.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrap">
<div id="divFields" runat="server">
<hr />
<telerik:RadTextBox ID="rtb_ID" Visible="false" runat="server"></telerik:RadTextBox>
<table cellspacing="3" cellpadding="3" border="0">
<tr>
<td valign="top"> </td>
<td valign="top">
<asp:button id="RadButton1" runat="server" text="Submit" AutoPostBack="true" CausesValidation="false" OnClick="RadButton1_Click"></asp:button>
</td>
</tr>
</table>
</div>
<div id="divSent" runat="server">
<p>Your injury assessment has been submitted. <asp:HyperLink ID="hlSendAnother" runat="server" NavigateUrl="~/Default.aspx" Text="Send another"></asp:HyperLink>.</p>
</div>
</div>
</form>
</body>
</html>
默认.aspx.vb
Imports Telerik.Web.UI
Imports System.Net
Imports System.Net.Mail
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
Inherits System.Web.UI.Page
Public Testing As Boolean = False
Protected Sub Default_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
divSent.Visible = False
If Request.QueryString("iid") IsNot Nothing Then
rtb_ID.Text = Request.QueryString("iid")
Else
rtb_ID.Text = Guid.NewGuid.ToString
End If
If Testing Then
rtb_Event.Text = "Test"
rdp_Date.SelectedDate = "01/01/2001"
rtb_Email.Text = "email@address.com"
rtb_RespondingAT.Text = "Responding AT"
End If
End Sub
Protected Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
Page.Validate()
End Sub
End Class
网络.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="BIR_Injuries.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<connectionStrings>
<!--<add name="birinjury" providerName="System.Data.SqlClient" connectionString="Data Source=smcdevprtl01;Initial Catalog=BaylorInjuryForm_Dev;User ID=birinjury;Password=#password#;" />-->
<add name="birinjury" providerName="System.Data.SqlClient" connectionString="Data Source=10.9.5.111;Initial Catalog=BaylorInjuryForm;User ID=birinjury;Password=#password#;"/>
</connectionStrings>
<appSettings>
<add key="Telerik.Skin" value="WebBlue"/>
<add key="Telerik.ScriptManager.TelerikCdn" value="Disabled"/>
<add key="Telerik.StyleSheetManager.TelerikCdn" value="Disabled"/>
<add key="EmailFrom" value="webmaster@address.com" />
<add key="EmailCC" value="webmaster@address.com" />
<add key="EmailTo" value="webmaster@address.com" />
<add key="SMTPServer" value="172.23.0.71" />
</appSettings>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
</compilation>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
</controls>
</pages>
<httpHandlers>
<add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false"/>
<add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false"/>
<add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/>
<add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false"/>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>
</httpHandlers>
<httpModules>
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule"/>
<add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
</httpModules>
<httpRuntime maxRequestLength="5120" executionTimeout="120"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="RadUploadModule"/>
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode"/>
<remove name="RadCompression"/>
<add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode"/>
</modules>
<handlers>
<remove name="ChartImage_axd"/>
<add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode"/>
<remove name="Telerik_Web_UI_SpellCheckHandler_axd"/>
<add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode"/>
<remove name="Telerik_Web_UI_DialogHandler_aspx"/>
<add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode"/>
<remove name="Telerik_RadUploadProgressHandler_ashx"/>
<add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode"/>
<remove name="Telerik_Web_UI_WebResource_axd"/>
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode"/>
</handlers>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="5242880"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
我可以推荐两件小事来尝试从按钮中删除AutoPostBack="true",并为表单提供操作属性。
因为如果未设置操作或将其设置为操作='#' IIS 6 可能会出现问题