[英]image button click event not firing on all pages Site.master
I have a Site.master page with an onserverclick event which works fine when I load some .aspx pages but then on some of the pages the event in the Site.master page does not fire at all. 我有一个带有onserverclick事件的Site.master页面,当我加载一些.aspx页面时,该页面工作正常,但是在某些页面上,Site.master页面中的事件根本不会触发。 Really doesnt make sense and was hoping that someone could give me an indication as to why this is? 真的没有道理,并希望有人可以给我指示为什么会这样吗?
this is the button in the master page. 这是母版页中的按钮。
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Pandora.Web.WebForms.SiteMaster" %>
<input type="image" runat="server" id="btnSearchFunction" src="Images/searchIcon.png" name="image" width="16" height="20" onserverclick="btnSearchFunction_Click" />
protected void btnSearchFunction_Click(Object sender, EventArgs e)
{
//code
}
This is an example of a page where the event in Site.master does not want to fire 这是一个页面示例,其中Site.master中的事件不希望触发
<%@ Page Title="TopicsPage" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="TopicPage.aspx.cs" Inherits="Pandora.Web.WebForms.TopicPage" %>
Sorry if it all comes accross as a bit vague 抱歉,如果所有内容都含糊不清
It is mysterious. 这是神秘的。 My only thought here is that there is another javascript error on some of the pages that is stopping the onserverclick event from running ie the underlying __doPostback call. 我唯一的想法是,某些页面上还有另一个JavaScript错误正在阻止onserverclick事件的运行,即基础__doPostback调用。
I would run the pages that are at fault through firebug/chrome developer tool bar (etc..) and look on the console for javascript errors 我会通过firebug / chrome开发人员工具栏(等)运行有问题的页面,并在控制台上查找javascript错误
ALSO 也
Just to try - i would change the HtmlControl to an ImageButton (ie a webcontrol) just to see if that makes any difference - changing onserverclick to onclick. 只是尝试-我将HtmlControl更改为ImageButton(即Web控件)只是为了看看是否有任何区别-将onserverclick更改为onclick。 I don't think this is the problem though to be honest 老实说,我认为这不是问题
AND 和
I'm assuming that the pages that it doesn't work with are always the same pages (rather than it being truly intermittent). 我假设它无法使用的页面始终是同一页面(而不是真正的间歇性页面)。 If so - on those pages just try including the same button direct on the page. 如果是这样-在这些页面上,只需尝试在页面上直接包含相同的按钮即可。 Does it work then. 那可以吗 It will help isolate it down to the master page if that genuinely is the root cause 如果这确实是根本原因,它将有助于将其隔离到母版页。
Good luck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.