Multiple page form

All buttons between panels submit before the end of form

Page 1 of 1

0 Replies - 1027 Views - Last Post: 17 April 2008 - 08:20 AM Rate Topic: -----

#1 Larisa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-April 08

Multiple page form

Posted 17 April 2008 - 08:20 AM

I have survey that uses ASP.NET 1.1 technology (cannot switch to 2.0 because of legacy applications) I also use Dreamweaver
When I click on first button in first panel it tries to submit the whole page and I have DB error message that NULL is not excepted.

System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'how_often_cafe', table 'myDB.dbo.tbl_mytable; column does not allow nulls. INSERT fails.
I tried to change buttons to html buttons but then the onclick does not fire and I get a message that Do_page1() is not a member.
I use panels trying to avoid SQL injections and not use session variables.
I use stored procedure

Here is my code
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>

<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>



<MM:Insert
runat="server"
CommandText='<%# "up_CanteenSurvey" %>'
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_SQL") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_SQL") %>'
Expression='<%# Request.Form("MM_insert") = "canteen_survey" %>'
CreateDataSet="false"
IsStoredProcedure="true"
SuccessURL='<%# "includes/thankyou.html" %>'

Debug="true">
<Parameters>
  <Parameter Name="@R_variety" Value='<%# IIf((Request.Form("R_variety") <> Nothing), Request.Form("R_variety"), "") %>' Type="Decimal" />  
  <Parameter Name="@R_quality" Value='<%# IIf((Request.Form("R_quality") <> Nothing), Request.Form("R_quality"), "") %>' Type="Decimal" />  
  <Parameter Name="@R_value" Value='<%# IIf((Request.Form("R_value") <> Nothing), Request.Form("R_value"), "") %>' Type="Decimal" />  
  <Parameter Name="@R_hours" Value='<%# IIf((Request.Form("R_hours") <> Nothing), Request.Form("R_hours"), "") %>' Type="Decimal" />  
  <Parameter Name="@R_courtesy" Value='<%# IIf((Request.Form("R_courtesy") <> Nothing), Request.Form("R_courtesy"), "") %>' Type="Decimal" />  
  <Parameter Name="@R_atmosphere" Value='<%# IIf((Request.Form("R_atmosphere") <> Nothing), Request.Form("R_atmosphere"), "") %>' Type="Decimal" />  
  <Parameter Name="@R_overall" Value='<%# IIf((Request.Form("R_overall") <> Nothing), Request.Form("R_overall"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_quality" Value='<%# IIf((Request.Form("F_quality") <> Nothing), Request.Form("F_quality"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_variety" Value='<%# IIf((Request.Form("F_variety") <> Nothing), Request.Form("F_variety"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_atmosphere" Value='<%# IIf((Request.Form("F_atmosphere") <> Nothing), Request.Form("F_atmosphere"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_courtesy" Value='<%# IIf((Request.Form("F_courtesy") <> Nothing), Request.Form("F_courtesy"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_value" Value='<%# IIf((Request.Form("F_value") <> Nothing), Request.Form("F_value"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_hours" Value='<%# IIf((Request.Form("F_hours") <> Nothing), Request.Form("F_hours"), "") %>' Type="Decimal" />  
  <Parameter Name="@F_overall" Value='<%# IIf((Request.Form("F_overall") <> Nothing), Request.Form("F_overall"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_quality" Value='<%# IIf((Request.Form("V_quality") <> Nothing), Request.Form("V_quality"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_types" Value='<%# IIf((Request.Form("V_types") <> Nothing), Request.Form("V_types"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_assortment" Value='<%# IIf((Request.Form("V_assortment") <> Nothing), Request.Form("V_assortment"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_cleanliness" Value='<%# IIf((Request.Form("V_cleanliness") <> Nothing), Request.Form("V_cleanliness"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_value" Value='<%# IIf((Request.Form("V_value") <> Nothing), Request.Form("V_value"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_machines" Value='<%# IIf((Request.Form("V_machines") <> Nothing), Request.Form("V_machines"), "") %>' Type="Decimal" />  
  <Parameter Name="@V_overall" Value='<%# IIf((Request.Form("V_overall") <> Nothing), Request.Form("V_overall"), "") %>' Type="Decimal" />  
  <Parameter Name="@Overall" Value='<%# IIf((Request.Form("Overall") <> Nothing), Request.Form("Overall"), "") %>' Type="Decimal" />  
  <Parameter Name="@how_often_shop" Value='<%# IIf((Request.Form("how_often_shop") <> Nothing), Request.Form("how_often_shop"), "") %>' Type="Decimal" />  
  <Parameter Name="@how_often_cafe" Value='<%# IIf((Request.Form("how_often_cafe") <> Nothing), Request.Form("how_often_cafe"), "") %>' Type="Decimal" />  
  <Parameter Name="@Local" Value='<%# IIf((Request.Form("local") <> Nothing), Request.Form("local"), "") %>' Type="VarChar" />  
  
 <Parameter Name="@Comments" 
  Value='<%# IIf((Request.Form("AllComments") <> Nothing), Trim(Replace(Request.Form("AllComments"),"""","""""")), "") %>' Type="VarChar"  />
  
</Parameters>
</MM:Insert>

<MM:DataSet 
id="location"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_SQL3") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_SQL3") %>'
CommandText='<%# "SELECT dbo.tblmine.Location1  FROM dbo.tblmine  ORDER BY dbo.tblmine.Location1" %>'
Debug="true"
></MM:DataSet>

<MM:PageBind runat="server" PostBackBind="true" /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<script Language="VB" runat="server">
	Sub Page_Load(sender As Object, e As EventArgs)
		' If this is first run set page number to 1
		If Not Page.IsPostBack Then
			PageNumber.Text = 1
		End If

		ShowCurrentPage()
	End Sub

	Sub btnBack_onclick(sender As Object, e As EventArgs)
		PageNumber.Text = PageNumber.Text - 1
		ShowCurrentPage()
	End Sub

	Sub btnNext_onclick(sender As Object, e As EventArgs)
		PageNumber.Text = PageNumber.Text + 1
		ShowCurrentPage()
	End Sub

	Sub ShowCurrentPage()
		' Set default state of panels and buttons
		panel1.Visible = False
		panel2.Visible = False
		panel3.Visible = False
		
		btnBack.Visible = True
		btnNext.Visible = True

		' Modify default state depending on current page
		Select Case PageNumber.Text
			Case 1
				panel1.Visible = True
				btnBack.Visible = False
			Case 2
				panel2.Visible = True
				
				' In case the user is coming back from page 3:
				btnNext.Text = "Next >"
			Case 3
				panel3.Visible = True
				
				' Let the user know this is the last step:
				btnNext.Text = "Finish"
		

				' This is where you would do whatever your form does.
				' I just echo the values back out to our display
				' controls on panel 4.
			
		End Select
	End Sub
	
</script>

</head>



<form runat="server">

<asp:Literal id="PageNumber" runat="server"
	Visible = "False"
/>

<asp:panel id="panel1" runat="server">
<table width="780px">
  <tr>
	<td colspan="8" class="header">Which canteen do you frequently visit? </td>
  </tr>
  <tr>
	<td  class="question" colspan="">Location</td>
	<td colspan="6" class="question" colspnan="2">

<asp:DropDownList  ID="local" runat="server" DataSource="<%# location.DefaultView %>" DataTextField="Location1" DataValueField="Location1"></asp:DropDownList><span class="maroon">Required</span></td>

	<td>&nbsp;</td>
  </tr>
  <tr>
	<td colspan="8" class="header">Retail Store </td>
  </tr>
  <tr>
	<td colspan="2" ></td>
	<td width="72">Poor</td>
	<td width="72">Fair</td>
	<td width="72">Neutral</td>
	<td width="72">Good</td>
	<td width="72">Excellent</td>
	<td width="72">N/A</td>
  </tr>
  <tr>
	<td colspan="2" class="question">Variety of merchandise offered </td>
	<td ><input type="radio" name="R_variety" value="1" /></td>
	<td><input type="radio" name="R_variety" value="2" /></td>
	<td><input type="radio" name="R_variety" value="3" /></td>
	<td><input type="radio" name="R_variety" value="4" /></td>
	<td><input type="radio" name="R_variety" value="5" /></td>
	<td><input type="radio" name="R_variety" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Quality of merchandise</td>
	<td><input type="radio" name="R_quality" value="1" /></td>
	<td><input type="radio" name="R_quality" value="2" /></td>
	<td><input type="radio" name="R_quality" value="3" /></td>
	<td><input type="radio" name="R_quality" value="4" /></td>
	<td><input type="radio" name="R_quality" value="5" /></td>
	<td><input type="radio" name="R_quality" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Provides value for money spent</td>
	<td><input type="radio" name="R_value" value="1" /></td>
	<td><input type="radio" name="R_value" value="2" /></td>
	<td><input type="radio" name="R_value" value="3" /></td>
	<td><input type="radio" name="R_value" value="4" /></td>
	<td><input type="radio" name="R_value" value="5" /></td>
	<td><input type="radio" name="R_value" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Hours of operation</td>
	<td><input type="radio" name="R_hours" value="1" /></td>
	<td><input type="radio" name="R_hours" value="2" /></td>
	<td><input type="radio" name="R_hours" value="3" /></td>
	<td><input type="radio" name="R_hours" value="4" /></td>
	<td><input type="radio" name="R_hours" value="5" /></td>
	<td><input type="radio" name="R_hours" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Courtesy/Friendliness of VCS employees</td>
	  <td><input type="radio" name="R_courtesy" value="1" /></td>
	<td><input type="radio" name="R_courtesy" value="2" /></td>
	<td><input type="radio" name="R_courtesy" value="3" /></td>
	<td><input type="radio" name="R_courtesy" value="4" /></td>
	<td><input type="radio" name="R_courtesy" value="5" /></td>
	<td><input type="radio" name="R_courtesy" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Store atmosphere (bright/clean/stocked)</td>

	 <td><input type="radio" name="R_atmosphere" value="1" /></td>
	<td><input type="radio" name="R_atmosphere" value="2" /></td>
	<td><input type="radio" name="R_atmosphere" value="3" /></td>
	<td><input type="radio" name="R_atmosphere" value="4" /></td>
	<td><input type="radio" name="R_atmosphere" value="5" /></td>
	<td><input type="radio" name="R_atmosphere" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Rate  your <u>overall</u> satisfaction with the Retail Store</td>
	 <td><input type="radio" name="R_overall" value="1" /></td>
	<td><input type="radio" name="R_overall" value="2" /></td>
	<td><input type="radio" name="R_overall" value="3" /></td>
	<td><input type="radio" name="R_overall" value="4" /></td>
	<td><input type="radio" name="R_overall" value="5" /></td>
	<td><input type="radio" name="R_overall" checked value="0" /></td>
  </tr></table>
</asp:panel>

<asp:panel id="panel2" runat="server">
<table> <tr>
	<td class="header" colspan="8">Food Court/Cafeteria</td>
  </tr>
  <tr>
	<td colspan="2"></td>
	<td>Poor</td>
	<td>Fair</td>
	<td>Neutral</td>
	<td>Good</td>
	<td>Excellent</td>
	<td>N/A</td>
  </tr>
  <tr>
	<td colspan="2" class="question">Quality of food offered</td>
	 <td><input type="radio" name="F_quality" value="1" /></td>
	<td><input type="radio" name="F_quality" value="2" /></td>
	<td><input type="radio" name="F_quality" value="3" /></td>
	<td><input type="radio" name="F_quality" value="4" /></td>
	<td><input type="radio" name="F_quality" value="5" /></td>
	<td><input type="radio" name="F_quality" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Variety of food selections offered</td>
 	<td><input type="radio" name="F_variety" value="1" /></td>
	<td><input type="radio" name="F_variety" value="2" /></td>
	<td><input type="radio" name="F_variety" value="3" /></td>
	<td><input type="radio" name="F_variety" value="4" /></td>
	<td><input type="radio" name="F_variety" value="5" /></td>
	<td><input type="radio" name="F_variety" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Atmosphere (clean/bright)</td>
 	<td><input type="radio" name="F_atmosphere" value="1" /></td>
	<td><input type="radio" name="F_atmosphere" value="2" /></td>
	<td><input type="radio" name="F_atmosphere" value="3" /></td>
	<td><input type="radio" name="F_atmosphere" value="4" /></td>
	<td><input type="radio" name="F_atmosphere" value="5" /></td>
	<td><input type="radio" name="F_atmosphere" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Courtesy/Friendliness of VCS employees&nbsp;&nbsp; </td>
 	<td><input type="radio" name="F_courtesy" value="1" /></td>
	<td><input type="radio" name="F_courtesy" value="2" /></td>
	<td><input type="radio" name="F_courtesy" value="3" /></td>
	<td><input type="radio" name="F_courtesy" value="4" /></td>
	<td><input type="radio" name="F_courtesy" value="5" /></td>
	<td><input type="radio" name="F_courtesy" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Value of food items purchased for money spent</td>
  
 	<td><input type="radio" name="F_value" value="1" /></td>
	<td><input type="radio" name="F_value" value="2" /></td>
	<td><input type="radio" name="F_value" value="3" /></td>
	<td><input type="radio" name="F_value" value="4" /></td>
	<td><input type="radio" name="F_value" value="5" /></td>
	<td><input type="radio" name="F_value" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Hours of operation</td>
	<td><input type="radio" name="F_hours" value="1" /></td>
	<td><input type="radio" name="F_hours" value="2" /></td>
	<td><input type="radio" name="F_hours" value="3" /></td>
	<td><input type="radio" name="F_hours" value="4" /></td>
	<td><input type="radio" name="F_hours" value="5" /></td>
	<td><input type="radio" name="F_hours" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Rate <u>overall</u> satisfaction with Food Court/Cafe</td>
	<td><input type="radio" name="F_overall" value="1" /></td>
	<td><input type="radio" name="F_overall" value="2" /></td>
	<td><input type="radio" name="F_overall" value="3" /></td>
	<td><input type="radio" name="F_overall" value="4" /></td>
	<td><input type="radio" name="F_overall" value="5" /></td>
	<td><input type="radio" name="F_overall" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="8" class="header">Vending</td>
  </tr>
  <tr>
	<td colspan="2"></td>
	<td>Poor</td>
	<td>Fair</td>
	<td>Neutral</td>
	<td>Good</td>
	<td>Excellent</td>
	<td>N/A</td>
  </tr>
  <tr>
	<td colspan="2" class="question">Quality of products offered</td>
	<td><input type="radio" name="V_quality" value="1" /></td>
	<td><input type="radio" name="V_quality" value="2" /></td>
	<td><input type="radio" name="V_quality" value="3" /></td>
	<td><input type="radio" name="V_quality" value="4" /></td>
	<td><input type="radio" name="V_quality" value="5" /></td>
	<td><input type="radio" name="V_quality" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Types of vending merchandise available</td>
	<td><input type="radio" name="V_types" value="1" /></td>
	<td><input type="radio" name="V_types" value="2" /></td>
	<td><input type="radio" name="V_types" value="3" /></td>
	<td><input type="radio" name="V_types" value="4" /></td>
	<td><input type="radio" name="V_types" value="5" /></td>
	<td><input type="radio" name="V_types" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Assortment of selections offered</td>
	<td><input type="radio" name="V_assortment" value="1" /></td>
	<td><input type="radio" name="V_assortment" value="2" /></td>
	<td><input type="radio" name="V_assortment" value="3" /></td>
	<td><input type="radio" name="V_assortment" value="4" /></td>
	<td><input type="radio" name="V_assortment" value="5" /></td>
	<td><input type="radio" name="V_assortment" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Cleanliness of vending area</td>
	<td><input type="radio" name="V_cleanliness" value="1" /></td>
	<td><input type="radio" name="V_cleanliness" value="2" /></td>
	<td><input type="radio" name="V_cleanliness" value="3" /></td>
	<td><input type="radio" name="V_cleanliness" value="4" /></td>
	<td><input type="radio" name="V_cleanliness" value="5" /></td>
	<td><input type="radio" name="V_cleanliness" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Value of products offered for money spent </td>
	<td><input type="radio" name="V_value" value="1" /></td>
	<td><input type="radio" name="V_value" value="2" /></td>
	<td><input type="radio" name="V_value" value="3" /></td>
	<td><input type="radio" name="V_value" value="4" /></td>
	<td><input type="radio" name="V_value" value="5" /></td>
	<td><input type="radio" name="V_value" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Machines full and operable</td>
	<td><input type="radio" name="V_machines" value="1" /></td>
	<td><input type="radio" name="V_machines" value="2" /></td>
	<td><input type="radio" name="V_machines" value="3" /></td>
	<td><input type="radio" name="V_machines" value="4" /></td>
	<td><input type="radio" name="V_machines" value="5" /></td>
	<td><input type="radio" name="V_machines" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Rate <u>overall</u> satisfaction with Vending</td>
	<td><input type="radio" name="V_overall" value="1" /></td>
	<td><input type="radio" name="V_overall" value="2" /></td>
	<td><input type="radio" name="V_overall" value="3" /></td>
	<td><input type="radio" name="V_overall" value="4" /></td>
	<td><input type="radio" name="V_overall" value="5" /></td>
	<td><input type="radio" name="V_overall" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="8" class="header" >Overall</td>
  </tr>
  <tr>
	<td colspan="2"></td>
	<td>Poor</td>
	<td>Fair</td>
	<td>Neutral</td>
	<td>Good</td>
	<td>Excellent</td>
	<td>N/A</td>
  </tr>
  <tr>
	<td colspan="2" class="question">How would you rate your  overall experience of shopping or dining at VCS?</td>
	<td><input type="radio" name="Overall" value="1" /></td>
	<td><input type="radio" name="Overall" value="2" /></td>
	<td><input type="radio" name="Overall" value="3" /></td>
	<td><input type="radio" name="Overall" value="4" /></td>
	<td><input type="radio" name="Overall" value="5" /></td>
	<td><input type="radio" name="Overall" checked value="0" /></td>
  </tr><table>
</asp:panel>

<asp:panel id="panel3" runat="server">
	<table>
		 <tr>
	<td colspan="2" class="question">How would you rate your  overall experience of shopping or dining at VCS?</td>
	<td><input type="radio" name="Overall" value="1" /></td>
	<td><input type="radio" name="Overall" value="2" /></td>
	<td><input type="radio" name="Overall" value="3" /></td>
	<td><input type="radio" name="Overall" value="4" /></td>
	<td><input type="radio" name="Overall" value="5" /></td>
	<td><input type="radio" name="Overall" checked value="0" /></td>
  </tr>
  <tr>
	<td colspan="2" class="question">How often do you shop at  the Canteen Retail Store?</td>
	<td colspan="6"><select name="how_often_shop">
	  <option value="0">Please choose</option>
	  <option value="1">Less than once a week</option>
	  <option value="2">1-2 days per week</option>
	  <option value="3">3-5 days per week</option>
	</select> 
	  <span class="maroon">Required</span>	 </td>
  </tr>
  <tr>
	<td colspan="2" class="question">How often do you visit the Food Court/Cafeteria? </td>
	<td colspan="6"><select name="how_often_cafe">
	  <option value="0">Please choose</option>
	  <option value="1">Less than once a week</option>
	  <option value="2">1-2 days per week</option>
	  <option value="3">3-5 days per week</option>
	</select>
	  <span class="maroon">Required</span></td>
  </tr>
  <tr>
	<td colspan="2" class="question">Comments:
	</td>
	<td colspan="6"><asp:TextBox Columns="40" ID="AllComments" Rows="3" runat="server"  TextMode="MultiLine" /></td>
  </tr>
  <tr>
	<td colspan="8" class="question"><asp:Button CommandName="Submit" CssClass="buttonchik" ForeColor="#000000" ID="Submit" runat="server" Text="Submit" onblur="Check"  ToolTip="Submit Information to VCS"  /></td>
  </tr>
</table>

</asp:panel>

<asp:Button id="btnBack" runat="server"
	Text	= "&lt; Back"
	onclick = "btnBack_onclick"
/>

<asp:Button id="btnNext" runat="server"
	Text	= "Next &gt;"
	onclick = "btnNext_onclick"
/>
<input type="hidden" name="MM_insert" value="canteen_survey">
</form>


</body>
</html>




--------------------------------------------------------------------------------

Is This A Good Question/Topic? 0
  • +

Page 1 of 1