ASP.NET 4.5, ImageButton OnClick not firing on Mas

2019-08-10 15:27发布

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

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.

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# MasterPage Code:

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

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

1条回答
走好不送
2楼-- · 2019-08-10 16:04

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

form1.Action = Request.Url.PathAndQuery;
查看更多
登录 后发表回答