Need help with ASP and C# form RRS feed

  • Question

  • Hey I am new to visual studio 2017 and I havnt programmed in years. I am making a web form with asp and C# I am having an issue getting the submit button to work. below is a small example of what I am doing

    asp from 

    <form id="mainInput" runat="server" method="post">

     <p class="lead">Report Number:
                <input id="reportNumber" type="text" /><p class="lead">
                <input id="submit" type="button" value="Submit"  runat="server" CssClass="hidden" OnClick="submit_Click" formmethod="post"/></p>



     protected void Page_Load(object sender, EventArgs e)

     protected void submit_Click(object sender, EventArgs e)

                    string reportNumber = Request.Form["reportNumber"];


    When I click submit nothing happens. When I debug and ht submit nothing happens. Can someone assist?

    • Moved by Sabah ShariqMVP Thursday, June 1, 2017 9:49 AM Moved From Visual C#
    Wednesday, May 31, 2017 9:20 PM

All replies

  • Not in front of my pc with VS, but things look valid.. Now you could try to add  runat="server" to the input "reportNumber" and then in the code behind access it like

    string reportNumber = reportNumber.Text ;

    Or you can also look at changing your button to a ASP:Button

    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

    • Edited by Cubangt Wednesday, May 31, 2017 9:27 PM
    Wednesday, May 31, 2017 9:26 PM
  • Hello,

    There is a dedicated forum for here

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, May 31, 2017 9:51 PM