1
我正在使用VS 2012/ASP.NET(網頁表單)4.5。我有一個傳統的用戶控制的頁面:Click事件不會在嵌套用戶控件中觸發,也不會調試
<%@ Page Title="" Language="C#" MasterPageFile="~/ControlCenter/MasterAdmin.master" AutoEventWireup="true" CodeFile="OrderDetail.aspx.cs" Inherits="ControlCenter_OrderDetail" %>
<%@ register src="~/Controls/OrderDetailMenu.ascx" tagprefix="eoi" tagname="OrderDetailMenu" %>
<asp:content ID="OrderDetailHead" ContentPlaceHolderID="head" Runat="Server">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="../Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery-ui-1.8.20.js"></script>
</asp:content>
<asp:content ID="OrderDetailBody" ContentPlaceHolderID="BodyContent" Runat="Server">
<table style="width: 100%;">
<tr>
<td colspan="4">
<eoi:orderdetailmenu id="OrderDetailMenu" runat="server" />
</td>
</tr>
..............
控制在內部,使用jQuery對話框顯示嵌套的用戶控件:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="OrderDetailMenu.ascx.cs" Inherits="Controls_OrderDetailMenu" %>
<%@ register src="~/Controls/UserComments.ascx" tagprefix="eoi" tagname="UserComments" %>
<%@ register src="~/Controls/OrderComments.ascx" tagprefix="eoi" tagname="OrderComments" %>
<script type="text/javascript">
$(document).ready(function()
{
//init dialog
$("#userCommentsPanel").dialog({
title: "Add User Comment",
height: 300,
width: 700,
autoOpen: false,
show: "puff",
hide: "puff",
buttons: [
{
text: "Close Window",
click: function()
{
$(this).dialog("close");
}
}
]
});
//popup link event
$("#addUserCommentsLink").click(function(e)
{
$("#userCommentsPanel").dialog("open");
e.preventDefault();
return false;
});
});
</script>
<table border="0" cellpadding="2" cellspacing="3">
<tr>
<td>
<a href="#" id="addUserCommentsLink" name="addUserCommentsLink">
Add User Comment
</a>
</td>
</tr>
</table>
<asp:panel id="userCommentsPanel" clientidmode="Static" runat="server">
<div class="userCommentsPopup">
<eoi:usercomments id="UserComments" runat="server" />
</div>
</asp:panel>
裏面的嵌套控制是簡單的形式,如下所示:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserComments.ascx.cs" Inherits="Controls_UserComments" %>
<table style="width:100%;" id="userCommentsFormTable" runat="server">
<tr>
<td width="1%"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">
<asp:validationsummary id="userCommentsSummary" runat="server" cssclass="validation" ShowModelStateErrors="true" />
</td>
</tr>
<tr>
<td>
<asp:textbox id="commentsBox" runat="server" columns="80" rows="5" textmode="MultiLine"></asp:textbox>
</td>
<td> </td>
</tr>
<tr>
<td align="right">
<asp:button id="commentsButton" runat="server" text="Save" onclick="commentsButton_Click" />
</td>
<td> </td>
</tr>
</table>
...事件處理程序:
protected void commentsButton_Click(object sender, EventArgs e)
{
//this method is never executed. :(
}
Page_Load觸發,但按鈕點擊事件不......沒有任何事情發生。這裏發生了什麼事?斷點也不會被擊中。就好像這個事件什麼都不做。我確信它與頁面生命週期醜陋有關,但我無法在Googleland中找到修復。
謝謝!
在這裏找到一些信息,這似乎是同樣的問題。 http://forums.asp.net/t/1002783.aspx/1 – 2013-04-03 20:29:01
假設它不能做...沒有答案,並沒有得到任何地方。 :( – 2013-04-15 20:52:22