i used asp.net user control in one of my MVC5 application. user controls call correctly and simply working, but i have problem in when i call any event used in user control are not postback. please give me any suggestion, where is issue and how can we use it. please help me to resolve.
see my code how i used in MVC5
user control code cs
public partial class uc_forum_two : ViewUserControl
{
if (!IsPostBack)
{
// some code here..
}
else {
// some code here..
}
}
user control ascx code
<form id="test" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnableTheming="True">
</telerik:RadScriptManager>
<asp:LinkButton OnClick="btnForumSearch_Click" ID="btnForumSearch"
runat="server">
<img src="/images/search_button.png" alt="search_button" />
</asp:LinkButton>
</form>
button code
protected void btnForumSearch_Click(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(txtForumSearch.Text))
{
Response.Redirect("/forum/search/" + txtForumSearch.Text.Replace(" ", "-"));
}
else
{
Response.Redirect("/forum/");
}
}
catch
{
}
View Code
@{
ViewBag.Title = "SmallBiz Org";
Layout = "~/Views/Shared/_ClientLayout.cshtml";
}
@{ Html.RenderPartial("~/UserControls/uc_forum_two.ascx"); }
any alternate way to use user controls with postback event in mvc5 razor view. Please do help if someone can,thanks for your time.