简体   繁体   English

并非在所有页面上都触发图像按钮单击事件

[英]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.

相关问题 在Site.Master页面中单击按钮会触发内容页面中的click事件。 - Button clicked in Site.Master page fires click event in content page. 从default.aspx单击时,放置在网站Site.Master上的按钮不会重定向,但是该按钮可在所有其他页面上使用 - Button placed on the website Site.Master doesn't redirect when clicked from default.aspx, however button works from all other pages 从另一个控件的click事件中使用CodeBehind更新Site.master控件 - Updating Site.master control using CodeBehind from a different control's click event javascript pageLoad函数没有在asp.net Site.Master中触发 - javascript pageLoad function not firing in asp.net Site.Master 我的所有观点都是强类型的,如何传递给site.master? - All my views are strongly typed, how to pass to site.master? “~/Site.Master”和“./Site.Master”的区别 - Difference between “~/Site.Master” and “./Site.Master” 单击Button控件事件中未触发的图像 - Click image within Button control event not firing Button On Click事件未触发 - Button On Click event not firing 按钮单击事件未触发 - Button Click Event Not Firing 当在网格视图内的更新面板内时,Asp 图像按钮单击事件不会为所有行触发 - Asp image button click event not firing for all row when it is inside a update panel which is inside a grid view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM