Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

sharonchapman7

Programmer
Aug 31, 2011
45
US
Hi,
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:

<pre lang="xml">&lt;%@ Page Language=&quot;VB&quot; AutoEventWireup=&quot;false&quot; CodeFile=&quot;default.aspx.vb&quot; Inherits=&quot;_default&quot;%&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;&lt;html xmlns=&quot;&lt;head id=&quot;Head1&quot; runat=&quot;server&quot;&gt;
&lt;title&gt;GDR Request Form&lt;/title&gt;

&lt;script src=&quot;Scripts/jquery-1.8.2.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;Scripts/jQuery.maskedinput.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;link href=&quot;Styles/style2.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;

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

&lt;/td&gt;
&lt;td width=&quot;25px&quot;&gt;
Date:&lt;/td&gt;
&lt;td&gt;
&lt;asp:TextBox ID=&quot;txtRequester_Date&quot; runat=&quot;server&quot; width=&quot;70px&quot;
ToolTip=&quot;Please Enter The Request Date. (MM/DD/YYYY)&quot;&gt;&lt;/asp:TextBox&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;/table&gt;
&lt;asp:Button ID=&quot;Button1&quot; runat=&quot;server&quot; Text=&quot;Submit&quot; /&gt;
&lt;br /&gt;

&lt;/div&gt;</pre>

***************************************************************************
default.aspx.vb
***************************************************************************
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
sqlConn.Open()
' execute the data insertion
sqlCmd.ExecuteNonQuery()
' close SQL connection
sqlConn.Close()
' dispose of the connection object (mostly optional but good practice)
sqlConn.Dispose()
' 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
 
May have better results posting this question in forum855



Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top