0

I have asp button on aspx view in mvc. When I click on button it's not giving any response

<script runat="server">
    private void GetReport(string mode = "")
    {
     ..................
    }
    protected void btnShowReport_Click(object sender, EventArgs e)
    {
        //This Event Not Firing.
        GetReport("print");
    }

 </script> 

 <form id="form1" runat="server" >
         //This Button Click is not Working
      <asp:Button ID="btnShowReport" OnClick="btnShowReport_Click" runat="server" Text="Get Last Report"  />

 </form>
5
  • 2
    This has nothing to do with MVC Commented Oct 8, 2015 at 8:12
  • This is my aspx view and its page directive is <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> @Stephen Muecke Commented Oct 8, 2015 at 8:15
  • 2
    There is no runat="server" in MVC and no code behind events - this is WebForms code Commented Oct 8, 2015 at 8:17
  • runat="server" comes after adding asp server control in (aspx view) and i have page load event also which is working but having problem in click event.. Commented Oct 8, 2015 at 8:21
  • You cannot do this. MVC does not support code behind events (your btnShowReport_Click method) or ViewState. Commented Oct 8, 2015 at 8:43

1 Answer 1

1

If you are using MVC, avoid these asp.net controls. Use plain HTML controls or use HTML helpers. One of the purposes of using ASP.NET MVC is to have grater control over the code that gets rendered.

Sign up to request clarification or add additional context in comments.

1 Comment

Actually I want to show crystal report on my page so I cannot show crystal report without CrystalReportViewer (which is asp control).that why I am having to use asp.net control

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.