Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of Daniel Reynolds
Daniel Reynolds
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k_smee
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>
Avatar of k_smee

ASKER

Thanks for the help on this!
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">