I have this textbox and submit button in a 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 executes when a 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");
}
}
It works from any page, except from the home page. If you access the homepage with /Default.aspx it works.
this is the site http://www.quotestemple.com
After looking at your website and attempting to regenerate what’s happening there using your posted code above, it seems you haven’t put an OnClick event on the search button. So when the button is clicked, it’s only doing a postback without going through the code so there’s no event to fire.
Try adding OnClick=”btnSearch_Click” to the button.