Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET 3.5 Validation not working.

Posted on 2010-11-22
9
Medium Priority
?
670 Views
Last Modified: 2012-08-13
On this "Purchase Requisition" form I've got a ValidationSummary control and a couple of RequiredFieldValidator controls, one on a TextBox and one on a RadioButtonList.  When I click the Submit button with all the fields blank, the form submits without the Validation controls firing.  The "btnSubmit.Attributes.Add("onclick", "doPrint()")" does make the print dialog pop up as intended and I'm not sure if this is causing a problem with Validation.  I can't think of what else may be the problem.  Here is my Page_Load event and below is the entire .aspx page.  I hope someone can help.  Thanks.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'This adds the overflow attribute to the TextBox so the vertical scroll bars can be removed.
        txtRemarks.Attributes.Add("style", "overflow :hidden")
        txtReasonForRequest.Attributes.Add("style", "overflow :hidden")
        txtReasonForModification.Attributes.Add("style", "overflow :hidden")

        '' On Page Load pull the Top Purchase Req Number and increment it by one.  ReqNumber += 1
        If Not IsPostBack Then
            Call GetLastRequisitionNumber()
            lblPurchaseRequisitionNumber.Text = TopReqID + 1
        End If

        btnSubmit.Attributes.Add("onclick", "doPrint()")
        iUserName = Right(Request.ServerVariables("AUTH_USER"), (Request.ServerVariables("AUTH_USER").Length - 5))  'Remove the five characters: "DOMA\"
        lblUserName.Text = iUserName
        lblCreatedBy.Text = "Created by: " & iUserName
End Sub
<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="PurchaseRequisition" %>

<!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 runat="server">
    <title>Purchase Requisition</title>

    <script type="text/javascript">
      function pageLoad() {
      }
    </script>

<%--Start jQuery scripts to Auto-Grow any Multi-Line TextBox on the page.--%>
<script src="js/jquery-1.4.2.js" type="text/javascript" ></script>
<script src='js/jquery.autogrow-textarea.js' type='text/javascript' ></script>
<script type='text/javascript'>
	$(function() {
		$('textarea').autogrow();
	});
</script>	
<%--End jQuery scripts to Auto-Grow any Multi-Line TextBox on the page.--%>
    

	<script type="text/javascript">
		// Fix the rounding error
		// Round() will give you back a number, accurate to the number of decimal places you specify, 
		// and RoundFixed() returns a string fixed to the required number of decimal places, 
		// e.g. useful when dealing with currency, £1.2 is accurate but better represented as £1.20.
		function Round(Number, DecimalPlaces) {
			return Math.round(parseFloat(Number) * Math.pow(10, DecimalPlaces)) / Math.pow(10, DecimalPlaces);
		}

		function RoundFixed(Number, DecimalPlaces) {
			return Round(Number, DecimalPlaces).toFixed(DecimalPlaces);
		}
	// Maybe this will add the decimal ?  There was a calculation error where 3 * 2.55 = 7.64 instead of 7.65 so I'm using RoundFixed instead.
	/*	function dp(price) {
			string = "" + price;
			number = string.length - string.indexOf('.');
			if (string.indexOf('.') == -1)
				return string + '.00';
			if (number == 1)
				return string + '00';
			if (number == 2)
				return string + '0';
			if (number > 3)
				return string.substring(0, string.length - number + 3);
			return string;
		}*/

		// Using .toFixed(2)  Check accuracy and maybe use .toPrecision(4) or something to correct.  Experiment with values in ()
		// Using .toFixed(2)  Check accuracy and maybe use .toPrecision(4) or something to correct.  Experiment with values in ()
		// Start Original Function
		// Use onkeyup="CalculateTotal_1(this), CalculateTOTAL(this)" 
		/*
		function CalculateTotal_1() {
		var ret1 = RoundFixed(parseInt(document.getElementById('txtQTY_1').value)
		* parseFloat(document.getElementById('txtUNIT_1').value), 2);
		document.getElementById('txtTotal_1').value = ret1;
		}
		function CalculateTotal_2() {
		var ret2 = RoundFixed(parseInt(document.getElementById('txtQTY_2').value)
		* parseFloat(document.getElementById('txtUNIT_2').value), 2);
		document.getElementById('txtTotal_2').value = ret2;
		}
		function CalculateTotal_3() {
		var ret3 = RoundFixed(parseInt(document.getElementById('txtQTY_3').value)
		* parseFloat(document.getElementById('txtUNIT_3').value), 2);
		document.getElementById('txtTotal_3').value = ret3;
		}
		function CalculateTOTAL() {
		document.getElementById('txtTOTAL').value = RoundFixed
		(
		parseFloat(document.getElementById('txtTotal_1').value)
		+ parseFloat(document.getElementById('txtTotal_2').value)
		+ parseFloat(document.getElementById('txtTotal_3').value), 2
		);
		}
		*/
		// End Original Function

		// Start Function from leakim971 on EE - http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26500533.html#a33765347
		// Use onkeyup="doCalc(this)"
		/*
		function doCalc() {
		var total1 = document.getElementById("txtQTY_1").value * document.getElementById("txtUNIT_1").value;
		var total2 = document.getElementById("txtQTY_2").value * document.getElementById("txtUNIT_2").value;
		var total3 = document.getElementById("txtQTY_3").value * document.getElementById("txtUNIT_3").value;

		    total1 = (isNaN(total1) ? 0 : total1).toFixed(2);
		total2 = (isNaN(total2) ? 0 : total2).toFixed(2);
		total3 = (isNaN(total3) ? 0 : total3).toFixed(2);

		    document.getElementById("txtTotal_1").value = total1;
		document.getElementById("txtTotal_2").value = total2;
		document.getElementById("txtTotal_3").value = total3;

		    document.getElementById("txtTOTAL").value = (parseFloat(total1) + parseFloat(total2) + parseFloat(total3)).toFixed(2);
		}
		*/
		// End Function from leakim971 on EE - http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26500533.html#a33765347

		// Start Function from mplungjan - http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26500533.html#a33765347
		// Use onkeyup="CalculateTOTAL()" 

		function getInt(str) {
			if (isNaN(str) || str == "") return 0;
			else return parseInt(str, 10)
		}
		function getFloat(str) {
			if (isNaN(str) || str == "") return 0;
			else return parseFloat(str)
		}

		function CalculateTotals(num) {
			var price = getFloat(document.getElementById('txtQTY_' + num).value) * getFloat(document.getElementById('txtUNIT_' + num).value);
			document.getElementById('txtTotal_' + num).value = price.toFixed(2);
			return price;
		}
		function CalculateTOTAL() {
			var total = 0;
			for (var i = 1; i <= 10; i++) {
				total += CalculateTotals(i);
			}
			document.getElementById('txtTOTAL').value = total.toFixed(2);
		}
/*  The function above is a little nicer.  Just change the number in " i <= 10 " to the number of rows on the Requisition form.
		function CalculateTOTAL() {
			var total = CalculateTotals(1) + CalculateTotals(2) + CalculateTotals(3) + CalculateTotals(4) + CalculateTotals(5) + CalculateTotals(6);
			document.getElementById('txtTOTAL').value = total.toFixed(2);
		}
*/
		// End Function from mplungjan
	</script>    
    
<link rel="Stylesheet" type="text/css" media="screen" href="css/PurchaseReqScreen.css" />
<link rel="Stylesheet" type="text/css" media="print" href="css/PurchaseReqPrint.css" />
<!--[if lte IE 7]>     
<style type="text/css" media="all">     
@import "css/fieldset-styling-ie.css"; 
legend {     
position: relative;     
left: -7px;     
top: -0.75em;    
}    
fieldset ol {     
padding-top: 0.25em;    
}
</style>    
<![endif]-->

<style type="text/css">
.if5_400
{
	overflow:visible; 
/*	overflow-y:visible; */
/*	font-family:tahoma; */
/*	font-size:12px; */
/*	font-weight:bold; */
	border:0px;
	background-image:url(images/tabck1.gif);
	line-height:18px;
	width:400; 
	text-decoration:underline;}

table
{
	border-collapse:collapse;
	border-color:#EEEEEE;
	margin-left:auto;
	margin-right:auto;
	/* width:95%; */
	font-family: Arial;
	font-size:small;
}
td
{
	border-color:#EEEEEE;
	}
th
{
	border-color:#EEEEEE;
	}
.divider
{
	line-height: 5px;
	background-color:#AAAAAA;
	}
/* style Name label and textbox... 
label
{
width: 4em;
float: left;
text-align: right;
margin-right: 0.5em;
display: block
}
.submit input
{
margin-left: 4.5em;
} 
*/

/* http://articles.sitepoint.com/article/fancy-form-design-css/3 */
/* Test Area Styling */
/*
fieldset {   
margin: 1.5em 0 0 0;   
padding: 0;  
}  
legend {   
margin-left: 1em;   
color: #000000;   
font-weight: bold;  
}  
fieldset ol {   
padding: 1em 1em 0 1em;   
list-style: none;  
}  
fieldset li {   
padding-bottom: 1em;  
}  
fieldset.submit {   
border-style: none;  
}
*/
/* Make labels into block elements thus making them occupy the entire line putting them on top of the input elements */
/*
label {    
display: block;   
}
*/

/* Start Left-aligning Text Labels  Make labels left aligned */
label_XXX_01 {    
float: left;    
width: 10em;    
margin-right: 1em;   
}

fieldset li {    
float: left;    
/*clear: left;    */
width: 100%;    
padding-bottom: 1em;   
}
fieldset {    
float: left;    
clear: left;    
width: 100%;    
margin: 0 0 1.5em 0;    
padding: 0;   
}
fieldset.submit {    
float: none;    
width: auto;    
border: 0 none #FFF;    
padding-left: 12em;   
}
/* End Left-aligning Text Labels */

/* Start Right-aligning Text Labels (The only difference is the addition of the text-align: right; to the label) */
label_XXX_02 {    
float: left;    
width: 10em;    
margin-right: 1em;    
text-align: right;   
}
/* End Right-aligning Text Labels */
.TextBoxPadLeft
{
 margin-left:0px;
	}
	.style1
	{
		color: #006600;
	}
	.style2
	{
		color: maroon;
	}
#lbAdmin 
{
 float:right;
 margin-right:2em;
}
.DontShow
{
	display:none;
	}	
</style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
    </div>
    <div id="Header">
		<span class="left">
			<img alt="WorkForce One Logo Image" src="images/wf1_Logo_200x67.gif" style="width: 200px; height: 67px"  /> 
		</span>
				<h1 class="middle" style="position:relative; left:-100px;">PURCHASE REQUISITION</h1>
		<span class="right" style="font-family:Arial; font-size:x-large; margin-right:50px;">
		
			<asp:Label ID="lblUserName" runat="server" Text="" ForeColor="#CCCC77" Font-Size="Small" CssClass="DontPrint"></asp:Label>
			<asp:Label ID="lblPurchaseRequisitionNumber" runat="server" Text="REQ #"></asp:Label>
			<asp:Label ID="lblSubmitted" runat="server" Text="" ForeColor="#00CC00" CssClass="DontPrint"></asp:Label>
		</span>        
    </div>
	<div style="margin-left:auto; margin-right:auto; width:600px;">
		<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="ValGroup1" />
	</div>
    <div style="clear:both;" id="Body">
		<div style="text-align:center;">
			Date Issued: <asp:TextBox ID="txtDateIssued" runat="server" Width="75px" CssClass="UnderlineText" 
				TabIndex="1" />
			<cc1:CalendarExtender ID="txtDateIssued_CalendarExtender" runat="server" Enabled="True" 
				TargetControlID="txtDateIssued">
			</cc1:CalendarExtender>
			<script type="text/javascript">
				function pageLoad(sendor,e)
				{
					var calendarBehavior = $find("txtDateIssued_CalendarExtender");
					var calendarBehavior2 = $find("txtDateOfPO_CalendarExtender");
					calendarBehavior.set_selectedDate('<%=DateTime.Now.ToString() %>');
					calendarBehavior2.set_selectedDate('<%=DateTime.Now.ToString() %>');
				}
			</script>
			<span style="margin-left:20px;" />
			Deliver To: (Dept. & Location): <asp:TextBox ID="txtDeliverTo" runat="server" CssClass="if5_400" 
				TabIndex="5" />
			<asp:RequiredFieldValidator ID="reqDeliverTo" runat="server" ControlToValidate="txtDeliverTo" 
				ErrorMessage="Deliver To is a required field" ValidationGroup="ValGroup1">*</asp:RequiredFieldValidator>
		</div>
		<br />
    <table border="1" class="alternate">
		<thead>
			<tr>
				<th>ITEM #</th>
				<th>QTY</th>
				<th>COMPLETE DESCRIPTION FOR ORDERING</th>
				<th>UNIT $</th>
				<th>TOTAL $</th>
			</tr>
		</thead>
		<tr>
			<td style="text-align:center; white-space:nowrap; ">1</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_1" runat="server" Width="40px" 
					onkeyup="CalculateTOTAL()" TabIndex="10" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_1" runat="server" Width="610px" 
					TabIndex="11" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_1" runat="server" Width="60px" 
					onkeyup="CalculateTOTAL()" TabIndex="12" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_1" runat="server" Width="60px" 
					TabIndex="-1" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">2</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_2" runat="server" Width="40px" 
					onkeyup="CalculateTOTAL()" TabIndex="20" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_2" runat="server" Width="610px" 
					TabIndex="21" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_2" runat="server" Width="60px" 
					onkeyup="CalculateTOTAL()" TabIndex="22" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_2" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">3</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_3" runat="server" Width="40px" 
					onkeyup="CalculateTOTAL()" TabIndex="30" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_3" runat="server" Width="610px" TabIndex="31" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_3" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="32" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_3" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; white-space:nowrap; ">4</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_4" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="40" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_4" runat="server" Width="610px" TabIndex="41" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_4" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="42" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_4" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">5</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_5" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="50" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_5" runat="server" Width="610px" TabIndex="51" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_5" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="52" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_5" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">6</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_6" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="60" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_6" runat="server" Width="610px" TabIndex="61" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_6" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="62" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_6" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; white-space:nowrap; ">7</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_7" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="70" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_7" runat="server" Width="610px" TabIndex="71" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_7" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="72" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_7" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">8</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_8" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="80" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_8" runat="server" Width="610px" TabIndex="81" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_8" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="82" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_8" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">9</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_9" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="90" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_9" runat="server" Width="610px" TabIndex="91" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_9" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="92" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_9" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td style="text-align:center; ">10</td>
			<td style="text-align:center; "><asp:TextBox ID="txtQTY_10" runat="server" Width="40px" onkeyup="CalculateTOTAL()" TabIndex="100" /></td>
			<td style="text-align:center; "><asp:TextBox ID="txtDescription_10" runat="server" Width="610px" TabIndex="101" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtUNIT_10" runat="server" Width="60px" onkeyup="CalculateTOTAL()" TabIndex="102" /></td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTotal_10" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td colspan="3" style="text-align:left; ">&nbsp;
			</td>
			<td style="text-align:right; ">TOTAL</td>
			<td style="text-align:center; ">$<asp:TextBox ID="txtTOTAL" runat="server" Width="60px" /></td>
		</tr>
		<tr>
			<td colspan="5" height="60px" valign="bottom">
			&nbsp;&nbsp;Vice President Signature/Date:___________________________________&nbsp;&nbsp; Executive Signature/Date:___________________________________  <br />
			<span style="color:#999999; font-size:x-small; float:right; margin-right:7em; ">Purchases over $5,000.00 require Executive Signature.</span>
			</td>
		</tr>
		<tr>
			<td colspan="5" style="text-align:left; vertical-align:top;" valign="top"><br />
							<label for="txtReasonForRequest" style="vertical-align:top;">&nbsp;&nbsp;Reason For Request: </label><br />
							<asp:TextBox ID="txtReasonForRequest" runat="server" TextMode="MultiLine" Width="842px" 
								CssClass="TextBoxPadLeft" TabIndex="200" />
			</td>
		</tr>
    </table>
<br />
<br />

<table border="1" class="alternate">
			<tr>
				<th>DATE</th>
				<th>VENDOR/ADDRESS/ID#</th>
				<th>P.O. NO.</th>
				<th>FUNDING CODE INFO</th>
			</tr>
		<tr>
			<td><asp:TextBox ID="txtDateOfPO" runat="server" Width="75px" CssClass="TextBoxPadLeft" TabIndex="210" />
				<cc1:CalendarExtender ID="txtDateOfPO_CalendarExtender" runat="server" Enabled="True" 
					TargetControlID="txtDateOfPO">
				</cc1:CalendarExtender>
			</td>
			<td><asp:TextBox ID="txtVendorID" runat="server" Width="478px" TabIndex="220" /></td>
			<td><asp:TextBox ID="txtPONO" runat="server" Width="100px" TabIndex="230" /></td>
			<td><asp:TextBox ID="txtFundingCodeInfo" runat="server" Width="180px" TabIndex="240" /></td>
		</tr>
		<tr>
			<td colspan="4"><br />
			<label for="txtRemarks">&nbsp;&nbsp;Remarks:<br />
				</label>
				<asp:TextBox ID="txtRemarks" runat="server" Width="842px" 
					TextMode="MultiLine" CssClass="TextBoxPadLeft" TabIndex="300" /></td>
		</tr>
		<tr>
			<td colspan="4" height="40px" valign="bottom" style=" border-bottom-style:none;">
				&nbsp;&nbsp;Is the purchase off a State Contract? 
				<asp:RadioButtonList ID="radStateContract" runat="server" AutoPostBack="True" 
					RepeatDirection="Horizontal" RepeatLayout="Flow" TabIndex="400">
					<asp:ListItem>Yes</asp:ListItem>
					<asp:ListItem>No</asp:ListItem>
				</asp:RadioButtonList>
				<asp:RequiredFieldValidator ID="reqStateContract" runat="server" 
					ControlToValidate="radStateContract" 
					ErrorMessage="Is the purchase off a State Contract is a required field" SetFocusOnError="True" 
					ValidationGroup="ValGroup1">*</asp:RequiredFieldValidator>
			</td>
		</tr>
		<tr>
			<td colspan="4"height="40px" valign="bottom" style=" border-top-style:none;">
				<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
				<Triggers>
					<asp:AsyncPostBackTrigger ControlID="radStateContract"/>
				</Triggers>
					<ContentTemplate>
				<asp:label ID="lblStateContractNo" runat="server" Text="&nbsp;&nbsp;State Contract Number: " 
					Visible="False" /><asp:TextBox ID="txtStateContractNo" runat="server" Visible="False" TabIndex="500" />
					<span style="margin-left: 2em;" />
				<asp:label ID="lblContractEndDate" runat="server" Text="State Contract End Date: " Visible="False" />
						<asp:TextBox ID="txtStateContractEndDate" runat="server" Width="70px" Visible="False" 
							TabIndex="600" />
						<cc1:CalendarExtender ID="txtStateContractEndDate_CalendarExtender" runat="server" Enabled="True" 
							SelectedDate="1900-01-01" TargetControlID="txtStateContractEndDate">
						</cc1:CalendarExtender>
					</ContentTemplate>
				</asp:UpdatePanel>

			</td>
		</tr>
		<tr class="DontPrint">
			<td colspan="4" style="text-align:center;" height="80px">
				<asp:Button ID="btnSubmit" runat="server" Text="Submit and Print" onclientclick="printme()" 
					TabIndex="700" ValidationGroup="ValGroup1" />
					<span style="margin-left: 8em;" />
				<asp:Button ID="btnCancel" runat="server" Text="Cancel" onclientclick="window.close()" 
					TabIndex="800" />
				<asp:TextBox ID="isPrint" runat="server" Width="24px" CssClass="DontShow" ></asp:TextBox>
				<asp:LinkButton ID="lbAdmin" runat="server" CssClass="DontPrint" 
					PostBackUrl="~/PurchaseReqAdmin.aspx">Admin</asp:LinkButton>
			</td>
		</tr>
		<tr style="display:none;">
			<td colspan="5" style="text-align:left; vertical-align:top;" valign="top">
							<label for="txtReasonForModification" style="vertical-align:top; font-style:italic; ">&nbsp;&nbsp;Reason For Modification: </label><br />
							<asp:TextBox ID="txtReasonForModification" runat="server" TextMode="MultiLine" Width="842px" 
								CssClass="TextBoxPadLeft" TabIndex="0" />
			</td>
		</tr>
		<tr>
			<td colspan="4" style=" color:Navy; font-size:small; font-style:italic;">
				<label style="text-decoration:underline;">To be attached to Purchase Requisition: </label><br />
				 <span class="style1">$0.00 - $5,000.00: One written and one verbal quote;</span>
				 $5,000.00 - $15,000.00:  Two written quotes;
				 <span class="style2">$$15,001 - $25,000.00:  Three written quotes. </span>
			</td>
		</tr>
</table>
    </div>
    <div style="margin-left:800px;">
		<asp:Label ID="lblCreatedBy" runat="server" Text="___"></asp:Label>
	</div>
<%--	<div style="margin-left:200px;">
		<asp:Label ID="Label1" runat="server" Text="1"></asp:Label><br />
		<asp:Label ID="Label2" runat="server" Text="2"></asp:Label><br />
		<asp:Label ID="Label3" runat="server" Text="3"></asp:Label><br />
		<asp:Label ID="Label4" runat="server" Text="4"></asp:Label><br />
		<asp:Label ID="Label5" runat="server" Text="5"></asp:Label><br /><br />
	</div>--%>
            <div style="text-align: center; margin-top:70px; font-size:small; color:#CCCCCC;" 
		class="DontPrint">
                Copyright &copy; 2010 WorkForce One Employment Solutions
            </div>

            	
<script type="text/javascript">
	function printme() {
		window.print();
	}
	if (document.getElementById("isPrint").value == 1) print()
    </script>
 


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

Open in new window

0
Comment
Question by:megnin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 10

Expert Comment

by:Nash2334
ID: 34190331
Need to return from your JS function:

btnSubmit.Attributes.Add("onclick", "return doPrint()");
0
 
LVL 1

Author Comment

by:megnin
ID: 34191040
Oh, bless you. ;-)  I hope it's that simple.  I'll give it a try...
0
 
LVL 1

Author Comment

by:megnin
ID: 34191100
No joy.  :-(  Still no validation firing.

Should I or should I not put anyting in the "ValidationGroup" field of the properties of all the controls.  I think I started without it and when the validation didn't work I added a group name, "ValGroup1", to all of them.  No change.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 10

Expert Comment

by:Nash2334
ID: 34192731
Make sure the JS function is returning a value at the end as well, e.g. "return true;" at the end of the doPrint() function.
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34194337
0
 
LVL 1

Author Comment

by:megnin
ID: 34196567
Okay, I'm not quite sure how this happened, but here's what I found...

This is my "Submit and Print" button:
<asp:Button ID="btnSubmit" runat="server" Text="Submit and Print" onclientclick="printme()"  />

Note the "onclientclick="printme()"

Here's the JavaScript:
<script type="text/javascript">
      function printme() {
            window.print();
      }
      if (document.getElementById("isPrint").value == 1) print()
</script>


Okay, nothing wrong so far (I think).

Then... in my Page_Load I had this:
 btnSubmit.Attributes.Add("onclick", "return doPrint()")

I don't have a doPrint() script anywhere!  
I commented that out and the Validation started firing.  Go figure.
0
 
LVL 10

Accepted Solution

by:
Nash2334 earned 2000 total points
ID: 34196610
Looks like you were adding a JS script to fire two ways, one using the "onclientclick" attribute and the other in your codebehind using "Attributes.Add".  If there was never a "doPrint" JS function, there would be a JS error at click, which probably prevented the validators from firing.
0
 
LVL 1

Author Comment

by:megnin
ID: 34196659
Yeah, I was probably experimenting with different methods of making the submit button also launch the Print dialog box at the same time, that I found "Googling around", and that got left over.  ;-)

Thank you for the help.  I don't think I would have found it if you hadn't pointed me in the right direction.  :-)
0
 
LVL 1

Author Closing Comment

by:megnin
ID: 34196664
Thanks a bunch!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question