CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Hybrid View

  1. #1
    Join Date
    Jan 2012

    html page calls default.aspx.vb and gets Ispostback false

    I have an asp html page that allows the user to input data into a web page. When they click the submit button it calls a default.aspx.vb. The ISPostback is always false so it skips my sql add parameters. Here is the code:

    PHP Code:
    <pre lang="xml"><%@ Page Language="VB" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default"%>

    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url]
    html xmlns="[url]http://www.w3.org/1999/xhtml">[/url]
    head id="Head1" runat="server">
    title>GDR Request Form</title>

    script src="Scripts/jquery-1.8.2.js" type="text/javascript"></script>
        <script src="Scripts/jQuery.maskedinput.js" type="text/javascript"></script>

        <link href="Styles/style2.css" rel="stylesheet" type="text/css" />


        <form id="form1" runat="server">

        <div id="content" style="text-align:center" >
             <table class="ftitle2" >
                     <td style="text-align:left" width="295px">
                         Organization name (if different from the Sponsor):</td>
                         <asp:TextBox ID="txtOrganization" runat="server" Width="466px"></asp:TextBox>

                     <td width="25px">
                         <asp:TextBox ID="txtRequester_Date" runat="server" width="70px"
                            ToolTip="Please Enter The Request Date. (MM/DD/YYYY)"></asp:TextBox>

             <asp:Button ID="Button1" runat="server" Text="Submit" />
             <br />

    Imports System.Data.SqlClient
    Imports System.Data
    Partial Class _Default
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
        Handles Me.Load
            txtRequester_Date.Text = Date.Today
            txtRequestDate.Text = Date.Today
            If (IsPostBack) Then
                ' this creates the connection.
                Dim sqlConn As New SqlConnection("Data Source=JITC-PC\GEOINT; Initial catalog=DEV_GEOINT; Integrated Security=SSPI;")
                ' create the command object
                Dim sqlCmd As New SqlCommand("sp_InsertRequest", sqlConn)
                ' define the connection for the command object
                sqlCmd.Connection = sqlConn
                sqlCmd.CommandType = CommandType.StoredProcedure
                ' define the SQL parameter
                sqlCmd.Parameters.AddWithValue("@Org", txtOrganization.Text)
                sqlCmd.Parameters.AddWithValue("@REQ_Date", txtRequester_Date.Text)
                ' open the connection
                ' execute the data insertion
                ' close SQL connection
                ' dispose of the connection object (mostly optional but good practice)
                ' Notify the submission was accepted
                Response.Write("Thank-you for your Request!")
            End If
        End Sub
        Private Function isempty(ByVal p1 As Object) As String
            Throw New NotImplementedException
        End Function
    End Class
    Last edited by GremlinSA; October 21st, 2012 at 11:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.