我遇到了这个奇怪的问题,我的按钮点击事件没有触发。我已经尝试了几乎所有的可能性但仍然没有运气。谷歌搜索几个小时,但仍然没有帮助。有些人在不同的论坛上遇到了完全相同的问题,但没有具体的答案。我尝试了button_click事件,并尝试了registring事件处理程序,它们都不起作用。 在我的场景中,我有一个sitefinity5自定义模块,我在其中显示员工信息以及员工数据。在员工图片上点击我正在显示一个JQUERY对话框,我有这个按钮。当应用程序加载时,它会触发文件后面的page_load代码,当我首先点击员工图片时,它会触发page_load但是不会激活button_click。随后点击图片甚至不会触发Page_Load。 真的很感激任何人的帮助。以下是我的代码段。
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SitefinityWebApp.SfCtrlPresentation.OpenAccessDataProvider_a4a794260c0b4440b466f75d11146db8" Codebehind="OpenAccessDataProvider,a4a794260c0b4440b466f75d11146db8.ascx.cs" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Fields" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%--<%@ Register TagPrefix="jq" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>--%>
<telerik:RadListView ID="dynamicContentListView" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
<LayoutTemplate>
<ul class="sfitemsList sfitemsListTitleDateTmb">
<asp:PlaceHolder ID="ItemsContainer" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<li class="sfitem sfClearfix">
<h2 class="sfitemTitle">
<sf:DetailsViewHyperLink ID="DetailsViewHyperLink" TextDataField="Title" runat="server" />
</h2>
<sf:AssetsField ID="AssetsField1" runat="server" DataFieldName="Picture" />
<sf:SitefinityLabel ID="SitefinityLabel1" runat="server" Text='<%# Eval("Designation")%>' WrapperTagName="div" HideIfNoText="true" CssClass="sfitemShortTxt" />
<sf:SitefinityLabel ID="SitefinityLabel2" runat="server" Text='<%# Eval("CompanyName")%>' WrapperTagName="div" HideIfNoText="true" CssClass="sfitemShortTxt" />
<sf:AssetsField ID="AssetsField2" runat="server" DataFieldName="Documents"/>
</li>
</ItemTemplate>
</telerik:RadListView>
<sf:Pager id="pager" runat="server"></sf:Pager>
<sf:ResourceLinks ID="resourcesLinks" runat="server">
<sf:ResourceFile JavaScriptLibrary="JQuery" />
</sf:ResourceLinks>
<div class="dialogTest"> <br />
<br />
Please enter your email address: <input type="text" name="emailAddress" style="width: 300px;" /><br />
<br />
<asp:TextBox ID="txtBox" runat="server"></asp:TextBox> <br/>
<asp:LinkButton Runat="server" ID="btnSubmit" Text="Submit" /> <br/>
<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="False"
onclick="Button1_Click" />
<%--<button name="btnSubmit" onclick="btnSubmit_Click" >Submit</button>--%>
</div>
<script type="text/javascript">
$j = jQuery.noConflict();
$j(document).ready(function () {
$j(".sfClearfix .sfimageWrp img").click(function () {
$j(".dialogTest").addClass("open");
//return $j(this).attr("src");
});
});
</script>
//.cs file
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Modules.Events;
using Telerik.Sitefinity.Events.Model;
namespace SitefinityWebApp.SfCtrlPresentation
{
public partial class OpenAccessDataProvider_a4a794260c0b4440b466f75d11146db8 : System.Web.UI.UserControl
{
//protected override void OnLoad(EventArgs e)
//{
// base.OnLoad(e);
//}
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
btnSubmit.Click+= new EventHandler(btnSubmit_Click);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
}
答案 0 :(得分:0)
这是公共前端页面上的用户控件吗?进入页面属性(在管理员页面列表下的操作菜单中)并确保选中该框以启用ViewState
默认情况下,Sitefinity会禁用viewstate以提高性能。
希望这有用!