ASP.NET MasterPage Postback not working from master page
I have this textbox and submit button in MasterPage
<telerik:RadTextBox ID="txtsearch" runat="server" EnableViewState="false" Height="23px" Width="150px"></telerik:RadTextBox>
<asp:RadioButtonList ID="searchType" runat="server" EnableViewState="False" RepeatDirection="Horizontal" RepeatLayout="Table" Width="160px">
<asp:ListItem Selected="True" Value="1">Authors</asp:ListItem>
<asp:ListItem Value="2">Quotes</asp:ListItem>
</asp:RadioButtonList>
And here is the code in MasterPage
which is executed when the user clicks the search button
protected void btnSearch_Click(object sender, EventArgs e)
{
if (searchType.SelectedValue == "1")
{
Response.Redirect("~/quotes/authors/search/" + HttpUtility.HtmlEncode(txtsearch.Text)+"/1");
}
else
{
Response.Redirect("~/quotes/search/"+ HttpUtility.HtmlEncode(txtsearch.Text)+"/1");
}
}
Works from any page except the home page. If you visit the main page with /Default.aspx it works.
this is the site http://www.quotestemple.com
+3
source to share
1 answer
After looking at their site and trying to reconstruct what's going on there using your above code, it seems you haven't put the OnClick event on the search button. So when the button is clicked, it only does the postback without going through the code so that there is no event.
Try adding OnClick = "btnSearch_Click" to the button .
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"/>
+2
source to share