本文介绍了ASP.NET 4.5的ImageButton的OnClick不开火母版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版的ImageButton的,它不是射击onclick事件。在没有它的工作原理母版页。

I have an ImageButton in MasterPage and it's not firing OnClick Event. In pages without a masterpage it works.

的不具有母版如果你在搜索输入单词搞笑它的工作原理,但如果你试图从它使用了母版不会从母版火code。

http://www.quotehd.com/default.aspx does not have a masterpage and if you enter the word 'funny' in search it works, but if you try to search from http://www.quotehd.com/topics which uses the masterpage it does not fire the code from masterpage.

这是母版ASPX code:

this is the MasterPage aspx code:

<asp:ImageButton ID="lnkGo1" runat="server" CssClass="searchsubmit"
     ImageUrl ="/content/themes/pin/images/search.png" OnClick="lnkGo1_Click"
     CausesValidation="False" ViewStateMode="Disabled" EnableViewState="False">
</asp:ImageButton>

C#母版code:

C# MasterPage Code:

protected void lnkGo1_Click(object sender, ImageClickEventArgs e)
{
   Response.Redirect("~/quotes/search/words/" + HttpUtility.HtmlEncode(txtSearch1.Text));
}

在同一code适用于/default.aspx其中没有一个母版,但是只有当你访问与Default.aspx的网页

the same code works on /default.aspx which does not have a masterpage, but only if you access the homepage with default.aspx

推荐答案

我加入这行到母版的OnLoad,现在它的作品。

I have added this line to MasterPage OnLoad and now it works.

form1.Action = Request.Url.PathAndQuery;

这篇关于ASP.NET 4.5的ImageButton的OnClick不开火母版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 04:41