Avatar of k_smee
k_smee
 asked on

Go Back to Main Page ASP.NET Button

I have an .aspx file that has the following HTML in it for a button that takes the user to the maiin page "project3.html" I am new to HTML and ASP.NET and don't know how this button should work.

Here is the HTML for the button:

<p><p align="center"><INPUT type='submit' value="Back to Main"><a href="project3.html"></a>
</p>
<p><p align="center"><INPUT type='submit' value="Back to Main"><a href="project3.html"></a>
</p>

Open in new window

ASP.NET

Avatar of undefined
Last Comment
Daniel Reynolds

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Daniel Reynolds

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
k_smee

ASKER
Here is the whole page. I don't think I have form tag set up right:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
   If Not Page.IsPostBack
      BindData()
   End If
  End Sub


  Sub BindData()
    '1. Create a connection

    Const strConnStr as String = "Provider=OraOLEDB.Oracle;Persist Security Info=False;" & _
     "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=nova.umuc.edu)" & _
     "(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=acad)));User Id=CM485B09;Password=d5h6x7e6;"


    Dim objConn as New OleDbConnection(strConnStr)
    objConn.Open()
     
    '2. Create a command object for the query

    Const strSQL as String = "SELECT * FROM sale ORDER by sale_id"
    Dim objCmd as New OleDbCommand(strSQL, objConn)
     
    '3. Create/Populate the DataReader

    Dim objDR as OleDbDataReader
    objDR = objCmd.ExecuteReader()    
     
    dgSale.DataSource = objDR
    dgSale.DataBind()  
  End Sub

Sub dgSale_Delete(sender As Object, e As DataGridCommandEventArgs)
    'Get the sale_id of the row whose Delete button was clicked
    Dim Selected_sale_id as String = dgSale.DataKeys(e.Item.ItemIndex)
   
    'TODO: Delete the record from the database

    '1. Create a connection

    Const strConnStr as String = "Provider=OraOLEDB.Oracle;Persist Security Info=False;" & _
     "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=nova.umuc.edu)" & _
     "(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=acad)));User Id=CM485B09;Password=d5h6x7e6;"    
       
     Dim objConn as New OleDbConnection(strConnStr)
     objConn.Open()

     '2. Create a command object for the query
     Dim strDelSQL as String = "DELETE FROM sale WHERE sale_id =" & Selected_sale_id
     Dim objCmd as New OleDbCommand(strDelSQL, objConn)
     objCmd.ExecuteNonQuery()
     objConn.Close()    
   
    'TODO: Rebind the DataGrid
    BindData()

End Sub


</script>

<html>
<head>
</head>
<body>
<form runat="server">

<asp:DataGrid id="dgSale" table align="center" runat="server"
    AutoGenerateColumns="False" CellPadding="4"
    HeaderStyle-BackColor="Black"
    HeaderStyle-ForeColor="White"
    HeaderStyle-HorizontalAlign="Center"
    HeaderStyle-Font-Bold="True"
   
    OnDeleteCommand="dgSale_Delete"
    DataKeyField="sale_id">


  <Columns>


    <asp:ButtonColumn Text="Delete" CommandName="Delete" />
    <asp:BoundColumn DataField="sale_id" HeaderText="Sale ID" />
    <asp:BoundColumn DataField="agent_id" HeaderText="Agent ID" />
    <asp:BoundColumn DataField="home_id" HeaderText="Home ID" />
    <asp:BoundColumn DataField="cust_id" HeaderText="Customer ID" />
    <asp:BoundColumn DataField="contract_id" HeaderText="Contract ID" />
    <asp:BoundColumn DataField="sale_date" HeaderText="Sale Date" DataFormatString={0:dd.MM.yyyy} />
    <asp:BoundColumn DataField="actual_amount" HeaderText="Actual Amount" DataFormatString="{0:C2}" />

  </Columns>

       
       
</asp:DataGrid>
      <form action = "project3.html" method="get"
      <p><p align="center"><a href="project3.html"><input type="submit" value="Back To Main"/></a>

      </p>
      </form>

</form>
</body>
</html>
k_smee

ASKER
Thanks for the help on this!
Daniel Reynolds

add the >   to the end of the form open tag
you have      <form action = "project3.html" method="get"

should have <form action = "project3.html" method="get">
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy