I like to query based on some fields to generate a report: Date range, Department, Student with date range. I have the form to work on searching....
However, I need to calculate totals for each of these fields from a report.
For example: if I search for students and the search results are:
Department Date Range Student Cost
DeptA 1/1/2012-12/31/2012 StuA $100
DeptA 1/1/2012-12/31/2012 StuB $50
DeptA 1/1/2012-12/31/2012 StuC $50
How can I calculate the total of cost automatically online (= $200)?
Thanks.
Here is my code:
<%
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.open strCon
SelectStmt = "Select * From view_costs Where "
WhereClause = ""
WhereBetweenClause = "BETWEEN"
If Request("qryDepartment") <> "All Departments" Then
qryDepartment = replace(request("qryDepartment"),"'","''")
WhereClause = WhereClause & "Department = '" & qryDepartment & "' AND "
End If
If Request("qryStudents") <> "All Students" Then
WhereClause = WhereClause & "Name = '" & Request("qryStudents") & "' AND "
End If
sStartDate = Request("StartDate")
sEndDate = Request("EndDate")
If IsDate(sStartDate) And IsDate(sEndDate) Then
WhereClause = WhereClause & "(StartDate >= '" & sStartDate & "' AND EndDate <= '" & sEndDate & "') "
End If
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.open strCon
pstart = trim(request.form("pstart"))
pfinish = trim(request.form("pfinish"))
Set getDepartment = Server.CreateObject("ADODB.Recordset")
getDepartment.Open "Select Department from view_costs order by Department;",adoCon
Set getname = Server.CreateObject("ADODB.Recordset")
getname.Open "Select Name from view_costs order by Name;",adoCon
%>
<html>
<head>
<title>The Resport</title>
</head>
<body>
<table width="770" align="center">
<tr>
<td colspan="4" class="n"><span id="h3">Search Menu</span></td>
</tr>
<form method=Department action="Search.asp" name="Search">
<tr>
<td>
<% if not getDepartment.eof then %>
<select name="qryDepartment" size="1" title="Select a Department Name" style="width:200;background-color=#F5D0A9;">
<option selected>All Departments</option>
<% do until getDepartment.eof %>
<option><%= getDepartment("Department") %></option>
<% getDepartment.MoveNext
loop %>
</select>
<% end if %>
</td>
<td>
<% if not getname.eof then %>
<select name="qryStudents" size="1" title="Select a Student Name" style="width:200;background-color=#F5D0A9;">
<option selected>All Students</option>
<% do until getname.eof %>
<option><%= getname("Name") %></option>
<% getname.MoveNext
loop %>
</select>
<% end if %>
</td>
<%
%>
<td><span id="b"> Start:</span> <input name="StartDate" type="text" size="15" maxlength="12" value="<%=sStartDate%>">
<img src="calendar.gif" alt="calendar"></td>
<td><span id="b"> End:</span> <input name="EndDate" type="text" size="15" maxlength="12" value="<%=sEndDate%>">
<img src="calendar.gif" alt="calendar"></td>
</tr>
<tr class="search-bg">
<td colspan="6">
<input type="button" name="Submit" value="Search" onClick="if (isDate()) document.Search.submit();">
</tr></table>
<% If oRs.RecordCount = 0 Then %>
<p></p>
<% Else %>
<table width="960" align="center">
<form method="Department">
<tr bgcolor="#FE9A2E" height="25">
<td class="a"> Department Name</td>
<td class="a"> Student</td>
<td class="a"> Start</td>
<td class="a"> End</td>
<td class="a"> Cost</td>
</tr>
<tr>
<td><%=oRs("Department")%> </td>
<td><%=oRs("Name")%> </td>
<td><%=FormatDateTime(Month(oRs("StartDate")) & "/" & Day(oRs("StartDate")) & "/" & Year(oRs("StartDate")))%> </td>
<td><%=FormatDateTime(Month(oRs("EndDate")) & "/" & Day(oRs("EndDate")) & "/" & Year(oRs("EndDate")))%> </td>
<td <%=sRowStyle%>>$<%=oRs("Cost")%> </td>
</tr>
<% oRs.MoveNext %>
<% WEND %>
</table>
</td>
</tr>
</table>
<% oRs.close
set oRs = nothing
set adoCon = nothing
%>
Why not specify the fields in your SQL (instead of "SELECT * ..."), then add up the values via variables in the loop and output them in a new table row after the loop?
Or you could use SQLs SUM() function to query those values.
Related
I am getting XSS Poor Validation issue in the following code:
<TABLE cellpadding=0 cellspacing=1 border=0 style="table-layout:fixed">
<col width=20%>
<col width=13%>
<col width=20%>
<col width=13%>
<col width=20%>
<col width=13%>
<TR height=25>
<TD class=border_title_sub colspan=2 align=center>미작성</TD>
<TD class=border_title_sub colspan=2 align=center>임시저장중</TD>
<TD class=border_title_sub colspan=2 align=center>작성완료</TD>
</TR>
<%
do until (rs_1.EOF and rs_2.EOF and rs_3.EOF)
%>
<TR height=25>
<%
if rs_1.EOF then
%>
<TD class=border_text> </TD>
<TD class=border_text align=center> </TD>
<%
else
rs_1_check_name = rs_1("check_name")
rs_1_user_name = rs_1("user_name")
%>
<TD class=border_text><%=HTMLDecode(Server.HTMLEncode(rs_1_check_name))%></TD>
<TD class=border_text align=center><%=HTMLDecode(Server.HTMLEncode(rs_1_user_name))%></TD>
<%
end if
if rs_2.EOF then
%>
<TD class=border_text> </TD>
<TD class=border_text align=center> </TD>
<%
else
rs_2_check_name = rs_2("check_name")
rs_2_user_name = rs_2("user_name")
%>
<TD class=border_text><%=HTMLDecode(Server.HTMLEncode(rs_2_check_name))%></TD>
<TD class=border_text align=center><%=HTMLDecode(Server.HTMLEncode(rs_2_user_name))%></TD>
<%
end if
if rs_3.EOF then
%>
<TD class=border_text> </TD>
<TD class=border_text align=center> </TD>
<%
else
rs_3_check_name = rs_3("check_name")
rs_3_user_name = rs_3("user_name")
%>
<TD class=border_text><%=HTMLDecode(Server.HTMLEncode(rs_3_check_name))%></TD>
<TD class=border_text align=center><%=HTMLDecode(Server.HTMLEncode(rs_3_user_name))%></TD>
<%
end if
%>
</TR>
<%
if not rs_1.EOF then rs_1.movenext
if not rs_2.EOF then rs_2.movenext
if not rs_3.EOF then rs_3.movenext
loop
rs_1.close
rs_2.close
rs_3.close
set rs_1 = Nothing
set rs_2 = Nothing
set rs_3 = Nothing
%>
</TABLE>
Here, HTMLDecode is my custom function, which is defined as follows:
<%
Function HTMLDecode(sText)
Dim I
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, " ", Chr(32))
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
%>
As my data already encoded in the DB, I am using both Server.HTMLEncode("") [ To escape from Security SW ) and HTMLDecode("") [To display information properly].
Could you please help me on this.
I am new to ASP.I need to write a script for Download Excel in ASP.I tried but it is downloading the entire page content but I need to download the table from database.
Here is my code:
<%#Language="VBScript"%>
<form name="form1" id="form1" method="post">
<input type="hidden" name="action" value="sel">
<table>
<tr>
<td><input type="submit" name="submit" id="submit" value="Download Excel"></td>
</tr>
</table>
Hello World
<%
action = Request.Form("action")
If action="sel" Then
Response.ContentType = "application/octet-stream"
Response.ContentType = "application/vnd.ms-excel"
SET Conn = Server.CreateObject("ADODB.Connection")
Conn.OPEN "PROVIDER=SQLOLEDB;DATA SOURCE=10.1.1.1;UID=sa;PWD=root;DATABASE=Student"
dim Conn,Rs
set Rs=server.createobject("ADODB.recordset")
Rs.open "SELECT * FROM studentdetails",Conn
Response.AddHeader "Content-Disposition", "attachment; filename=xl_data.xls"
%>
<TABLE BORDER=1>
<TR>
<%
j = 2
For i = 0 to RS.Fields.Count - 1
%>
<TD width="18"><B>
<% = RS(i).Name %></B></TD>
<% Next %>
<TD width="42"></TD>
<TD width="53"></TD>
</TR>
<%
Do While Not RS.EOF
%>
<TR>
<% For i = 0 to RS.Fields.Count - 1
%>
<TD VALIGN=TOP><% = RS(i) %></TD>
<% Next %>
</TR>
<%
RS.MoveNext
j = j + 1
Loop
RS.Close
End If
%>
</TABLE>
In this program I have included Hello World line while downloading it is downloading that also.So Please give me some suggestions.THANKS IN ADVANCE.
replace
Response.ContentType = "application/octet-stream"
with
Response.Clear
otherwise you are sending the form and the table to Excel
I am trying to validate information, without switching the page (in this case a username, if the username is found, great, populate a textbox and dynamically create a table with the username it it). However, I am getting an error on line 75 that reads:
ADODB.Recordset
error '800a0e78'
Operation is not allowed when the object is closed.
/login.asp, line 75
I haven't closed the recordset anywhere. By my knowledge it should work. What am I doing wrong?
<%
Dim cn,rs
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.recordset")
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Open Server.MapPath("login.mdb")
'Default message for the user on the login page
msg = "Please login"
'Logout code. This code empties the session variable which holds the user's userID.
If Request.QueryString("action") = "logout" Then
Session("user_id") = ""
msg = "You have been logged out"
End If
'Check if the form has been submitted
If Request.Form("Submit") = "Test" Then
user_name = Request.Form("user_name")
user_pass = Request.Form("user_pass")
mySQL = "SELECT user_id, user_name, user_pass FROM users WHERE user_name = '" & user_name & "' AND user_pass = '" & user_pass & "'"
'Select the data from the database using the submitted data.
rs.Open mySQL, cn
'Check if a match was found.
If NOT rs.EOF Then
'Session("user_id") = rsLogin("user_id")
'Response.Redirect("profile.asp")
u = rs("user_name")
Else
'If a match was not found then output an error.
Response.Redirect("login.asp?errmsg=Login failed")
End If
End If
%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<table width="300" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>Username</td>
<td><input name="user_name" type="text" id="user_name" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="user_pass" type="password" id="user_pass" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Test" /></td>
</tr>
</table>
</form>
<input id="fileno" value="<%=u%>" type="text">
<%
While NOT rs.EOF
%>
<table width="200" border="1" cellspacing="0" cellpadding="2">
<tr>
<th scope="col"><div align="left">username</div></th>
</tr>
<tr>
<td><%=u%></td>
</tr>
<%
rs.MoveNext
Wend
%>
</table>
</body>
</html>
When this condition fails.
If Request.Form("Submit") = "Test"
your code tries to access rs.eof without opening the recordset.
Put the rs.open OUTSIDE of that block.
Means you haven't closed your connection object
try set cn =Nothing at the end of your page
i have a classic asp page with inside the following vbscript
but it say that the Document object dose not exist why??
TypeError (0x800a01a8): Object required: 'Document'
the vbscript code:
<script language="vbscript" RUNAT="Server">
Function getDescriptionEstProc()
Dim CONNECTSTRING, QUALIFIER, QueryDescEstProc, dbConnect, res,output, param
CONNECTSTRING = Session("CONNECTSTRING")
QUALIFIER = Session("QUALIFIER")
param = PageParams1.UIDMeterHistory
QueryDescEstProc = "select e.description from meterhistory mh, meterread m, estimationprocess e where m.uidestproc = e.uidestproc and m.uidmeter = mh.uidmeter and mh.uidmeterhistory = '"& "0100001" &"'"
Set dbConnect = Server.CreateObject("ADODB.Connection")
Set rsWQType = Server.CreateObject("ADODB.Recordset")
dbConnect.Open CONNECTSTRING
rsWQType.Open QueryDescEstProc, dbConnect
res = ""
Do While Not rsWQType.EOF
res = res & rsWQType("description") & ","
Loop
Dim TheForm
Set TheForm = Document.forms("Form1")
TheForm.hiddenString.Value = res
Response.Write res & " - hello"
getDescriptionEstProc = res
End Function
</script>
(there is no aspx file)
the .asp file:
<form name="Form1" method="post" onkeypress="if (event.keyCode==13) {this.submit();event.returnValue=false;} else event.returnValue=true;">
<input class="lookup" type=hidden name="Id" value="<%=PageParams1.Id%>">
<input type=hidden name="SessionId" value="<%=PageParams1.SessionId%>">
<input type=hidden name="Command" value="">
<input type=hidden name="AccountID" value="<%=PageParams1.AccountID%>">
<input type=hidden name="UIDFACILITY" value="<%=PageParams1.UIDFACILITY%>">
<input type=hidden name="FACILITYID" value="<%=PageParams1.FACILITYID%>">
<input type=hidden name="METERID" value="<%=PageParams1.METERID%>">
<input type=hidden name="UIDMETER" value="<%=PageParams1.UIDMETER%>">
<input type=hidden name="UIDMeterHistory" value="<%=PageParams1.UIDMeterHistory%>">
<input type=hidden name="CustomerName" value="<%=PageParams1.CustomerName%>">
<input type=hidden name="CustomerId" value="<%=PageParams1.CustomerId%>">
<input type=hidden name="EntityParam" value="<%=PageParams1.EntityParam%>">
<input type=hidden name="SORT_BY" value="<%=PageParams1.SORT_BY%>">
<input type=hidden name="SORT_ORDER" value="<%=PageParams1.SORT_ORDER%>">
<input type=hidden name="Mode" value="<%=PageParams1.Mode%>">
<table class="SnapIn" cellpadding="0" cellspacing="0" border=0><tr class="ToolsTabs">
<td class="Title"><nobr><%=Proxy1.i18n.FM("MeterHistory")%></nobr></td>
<td class="ToolsLeft">
<b><%=Proxy1.i18n.FM("ID")%></b> <%=meterId %>
<%if (PageParams1.Mode == "ServicePoint") {%>
| <a href="../../ccs/MainWebPart.aspx?Mode=
<%=PageParams1.Mode%>&SessionId=<%=PageParams1.SessionId%>&Uid=
<%=Proxy1.Session.GetPropertyValue("SERVICEPOINT_UID")%>">
<%=Proxy1.i18n.FM("ServicePointSummary")%></a>
<% } else if (PageParams1.Mode == "MarketParticipant") { %>
| <a href="../../ccs/MainWebPart.aspx?Mode=
<%=PageParams1.Mode%>&SessionId=<%=PageParams1.SessionId%>&Uid=
<%=Proxy1.Session.GetPropertyValue("MARKETPARTICIPANT_UID")%>">
<%=Proxy1.i18n.FM("MarketParticipantSummary")%></a>
<% } %>
</td>
<td class="ToolsRight"><nobr>
<%if (PageParams1.AccountID) {%>
<b><%=Proxy1.i18n.FM("AccountID")%></b>
<a class="Link" onclick='window.navigate("../viewaccount/Meters.asp?Id=<%= escape(PageParams1.AccountID)%>&SessionId=<%=PageParams1.SessionId%>")'><u><%=PageParams1.AccountID %></u></a>
<%} if (PageParams1.CustomerId) {%>
<b><%=Proxy1.i18n.FM("CustomerID")%></b>
<a class='Link' onclick='navigate("../../ccs/MainWebPart.aspx?Id=<%=escape(PageParams1.CustomerId)%>&SessionId=<%=PageParams1.SessionId%>"+"&Mode=Customer")'>
<%=PageParams1.CustomerId%>
</a>
<%} if (PageParams1.UIDFACILITY) {%>
<b><%=Proxy1.i18n.FM("FacilityID")%></b>
<a class=Link onclick='navigate("../cust_facility/Basics.asp?UIDFACILITY=<%=PageParams1.UIDFACILITY%>&SessionId=<%=PageParams1.SessionId%>&X_ROWPERPAGE=50")'>
<%=PageParams1.FACILITYID%>
</a>
<%}%>
</nobr></td>
</tr><tr>
<td class="TabBox" colspan="3"><%= RenderTabs("MeterRead") %></td>
</tr><tr>
<td class="Body" colspan="3">
<% if (OperationError) ReportError(OperationError)%>
<%if (PageParams1.Command=='Edit') { %>
<table width=100%><tr><td class=LinkBox>
<%if (Proxy1.Allow("//ACCTMGT/ACCTCOMP/ACCTMET/#UPDATE")) {%>
<%=Proxy1.i18n.FM("Save")%> |
<%}%>
<%if (PageParams1.EntityParam && Proxy1.Allow("//ACCTMGT/ACCTCOMP/ACCTMET/#REMOVE") ) { %><%=Proxy1.i18n.FM("Delete")%> |<% } %>
<%=Proxy1.i18n.FM("Cancel")%>
</td></tr></table>
<%} else%>
<%=tMeterHistoryTable %>
<%if (PageParams1.Command != 'Edit') { %>
<table style="width: expression(Math.max(document.body.offsetWidth-55, 540))">
<tr>
<td align=left>
<%
if (Proxy1.Allow("//FACILITY/ADD"))
{
%>
<a href="javascript: Edit()" ><%=Proxy1.i18n.FM("Add")%></a>
<%
}
if (Proxy1.Allow("//FACILITY/REEST_ACTION/#REESTIMATE")) { %>
Ristima
<%
}
if (Proxy1.Allow("//FACILITY/REEST_ACTION_2")) { %>
Ristima lettura conferimento
<% }
if (Proxy1.Allow("//FACILITY/REEST_ACTION/#DISCHARGE")) { %>
Scarta
<% } %>
</td>
<!--Indicazione righe e pagina-->
<td align=right>
<%= Paginator_b(PageParams1.ROWPERPAGE, PageParams1.PAGENUMBER) %>
</td>
</tr>
</table>
<%
}
%>
<div class="mAppScroll" style="height:100% width:100%"><% =tTable %></div>
<tr>
<td>
<!--Cannata Alberto - modifica del 09/10/2006: aggiorniamo i campi LSUSER e LSTIME della METERHISTORY.-->
<input type="hidden" name = "OLD_STATUS" value = "<%=oldstatus_str%>">
<input type="hidden" name = "X_LSUSER" value = "<%=username_web.toUpperCase()%>">
<input type="hidden" name = "X_LSTIME" value = "<%=data_modifica%>">
</td>
</tr>
</td>
</tr>
</table><!-- /SnapIn -->
<input type="hidden" id="hiddString" name="hiddenString" value="">
<%
getDescriptionEstProc();
%>
<SCRIPT language="javascript">
appendColumn();
</SCRIPT>
Document.Forms is not used in server-side ASP, it's used in client-side code such as Javascript and VBScript. If you are trying to post data with your form, look into using Request["fieldname"] to get the values you need.
It looks like you're just trying to set the value of the hidden field?
Since the function returns the value you want (res), just do this:
<input type="hidden" id="hiddString" name="hiddenString" value="<%=getDescriptionEstProc()%>">
Hope this helps.
Good luck.
so I have a slight issue with doing 2 things on a web page. I'm using a to upload a file to my web server, at the same time I have other used to get data from the user (first name, last name ect) The form is runat=server, the button that is supposed to upload the file (after some preliminary checking that the file is ok, and that the forms fields are filled out properly) is also runat server, with a onserver click.
The main issue is that, when I give the form a "get" method, I can get the desired result of having all my data in the url where I want it, but then I can't upload a file. While if I remove that tag, I can upload a file, but then I get no data in my url.
(Relevant code)
<script language="VB" runat="server">
Dim str As String
Sub Button1_Click(ByVal Source As Object, ByVal e As EventArgs)
'Dim submitFunction As String = "<script type='text/javascript'> function submitform() { document.myform.submit();}" & "</" & "script>"
Session("firstTime") = 4
Session("errCheck") = 1
If InputF.Value = "" Then
Span1.InnerHtml = "Error: you must enter a file name"
Return
End If
If Not (InputF.PostedFile Is Nothing) Then
Try
If Session("firstTime") <> 1 Then
If Request.QueryString("fName") = "" Then
str += "Please Enter your first name <br/>"
Session("errCheck") += 1
End If
If Request.QueryString("lName") = "" Then
str += "Please Enter your last name <br />"
Session("errCheck") += 1
End If
If Request.QueryString("addr1") = "" Then
str += "Please Enter your address <br />"
Session("errCheck") += 1
End If
If Request.QueryString("city") = "" Then
str += "Please Enter a city name <br />"
Session("errCheck") += 1
End If
If Len(Request.QueryString("prov")) <> 2 Then
str += "Please Enter a 2 character province <br />"
Session("errCheck") += 1
End If
If Len(Request.QueryString("pCode")) <> 6 Then
str += "Please Enter a valid postal code <br />"
Session("errCheck") += 1
End If
If Request.QueryString("hPhone") = "" Then
str += "Please Enter your home phone <br />"
Session("errCheck") += 1
ElseIf Len(Request.QueryString("hPhone")) <> 10 Then
str += "Please enter a 10 digit number for your home phone <br />"
Session("errCheck") += 1
End If
End If
If Session("errCheck") = 1 Then
InputF.PostedFile.SaveAs(("FILE PATH TO MY SERVER" & Request.QueryString("compName") & " - " & Request.QueryString("fName") & ", " & Request.QueryString("lName") & InputF.Value))
'Response.Redirect("default.aspx?fName=" & Request.QueryString("fName"))
End If
Catch exc As Exception
str += "Error Saving File"
Span1.InnerHtml = "Error saving file"
Session("errCheck") += 1
End Try
End If
End Sub 'Button1_Click
</script>
<form name="myform" id="myform" method="get" runat="server" enctype="multipart/form-data">
<table>
<h2><% If Session("errCheck") <> 1 Then
Response.Write(Str)
End If%></h2>
<tr>
<td align="right"><label>Resume/Documents</label></td>
<td><input type="file" runat="server" id="InputF" name="InputF" onchange="handleFiles(this.files)" /><input type="button" id="adder" value="add another document" onclick="addInput('dynamicInput');" /></td>
<div id="dynamicInput">
</div>
</tr>
<tr>
<td>
<span id=Span1
style="font: 8pt verdana;"
runat="server" />
</td>
</tr>
<input type="hidden" id="Hidden13" name="compName" value="<% response.Write(request.QueryString("compName")) %>" />
<input type="hidden" id="posCode" name="posCode" value="<% response.Write(request.QueryString("posCode"))%>" />
<input type="hidden" id="reqNum" name="reqNum" value="<% response.Write(request.QueryString("reqNum")) %>" />
<input type="hidden" id="company" name="company" value="<% response.Write(request.QueryString("company"))%>" />
<input type="hidden" id="division" name="division" value="<% response.Write(request.QueryString("division")) %>" />
<input type="hidden" id="department" name="department" value="<% response.Write(request.QueryString("department"))%>" />
<tr>
<td align="right">First name<span style="color:Red;">*</span>:</td>
<td><input type='text' name='fName' id='fName' size='50' maxlength="50"value="<% Response.Write(Request.QueryString("fName"))%>" /></td>
</tr>
<tr>
<td align="right"><label>Last name </label><span style="color:Red;">*</span>:</td>
<td><input type='text' name='lName' id='lName' size='50' maxlength="50" value="<% response.Write(request.QueryString("lName"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Initial</label>:</td>
<td><input type='text' name='init' id='init' size='2' maxlength="2" value="<% response.Write(request.QueryString("init"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Email</label>:</td>
<td><input type='text' name='email' id='email' size='50' maxlength="50" value="<% response.Write(request.QueryString("email"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Address 1</label><span style="color:Red;">*</span>:</td>
<td><input type='text' name='addr1' id='addr1' size='25' maxlength="25" value="<% response.Write(request.QueryString("addr1"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Address 2</label>:</td>
<td><input type='text' name='addr2' id='addr2' size='25' maxlength="25" value="<% response.Write(request.QueryString("addr2"))%>"/></td>
</tr>
<tr>
<td align="right"><label>City</label><span style="color:Red;">*</span>:</td>
<td><input type='text' name='city' id='city' size='25' maxlength="25" value="<% response.Write(request.QueryString("city"))%>"/></td>
</tr>
<br />
<tr>
<td align="right"><label>Province</label><span style="color:Red;">*</span>:</td>
<td><input type='text' name='prov' id='prov' size='2' maxlength="2" value="<% response.Write(request.QueryString("prov"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Country</label>:</td>
<td><input type='text' name='count' id='count' size='25' maxlength="25" value="<% response.Write(request.QueryString("count"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Postal code</label><span style="color:Red;">*</span>:</td>
<td><input type='text' name='pCode' id='pCode' size='25' maxlength="25" value="<% response.Write(request.QueryString("pCode"))%>"/></td>
</tr>
<tr>
<td align="right"><label>Home Phone</label><span style="color:Red;">*</span>:</td>
<td><input type='text' name='hPhone' id='hPhone' size='15' maxlength="15" value="<% response.Write(request.QueryString("hPhone"))%>"/></td>
<p>Format for phone numbers: Areacode, phone number, no spaces, no dashes ie: 2041231234</P>
</tr>
<tr>
<td align="right"><label>Work Phone</label>:</td>
<td><input type='text' name='wPhone' id='wPhone' size='25' maxlength="25" value="<% response.Write(request.QueryString("wPhone"))%>"/></td>
</tr>
</table>
<input type=button
id="Button1"
value="Submit Application"
OnServerClick="Button1_Click"
runat="server" />
</form>
I was close to getting this myself. On form submit, I do all the validation for the other files, then if all checks out, I submit the form to a different page(with other non-relevant code).
Basically the code I posted is good, I was just missing a few things for when it's submitted
In short:
'if there are no errors with the user feilds
If Session("errCheck") = 1 Then
Try
If Not (System.IO.Path.GetFileName(InputF.PostedFile.FileName.ToString()) Is Nothing) Then
Try
InputF.PostedFile.SaveAs(("somepath:\somepath\somepath\somepath\" & Trim(Request.Form("compName")) & " - " & Request.Form("lName") & ", " & Request.Form("fName") & "-" & System.IO.Path.GetFileName(InputF.PostedFile.FileName.ToString())))
Catch ex As Exception
Session("errCheck") += 1
str += "Error Saving File" & ex.Message
End Try
If Session("errCheck") = 1 Then
Response.Redirect("final2.aspx?fName=" & Request.Form("fName") & "&lName=" & Request.Form("lName") & "&compName=" & Trim(Request.Form("compName")) &
"&posCode=" & Request.Form("posCode") & "&reqNum=" & Request.Form("reqNum") & "&company=" & Request.Form("company") &
"&division=" & Request.Form("division") & "&department=" & Request.Form("department") & "&init=" & Request.Form("init") &
"&email=" & Request.Form("email") & "&addr1=" & Trim(Request.Form("addr1")) & "&addr2=" & Request.Form("addr2") &
"&city=" & Request.Form("city") & "&prov=" & Request.Form("prov") & "&count=" & Request.Form("count") &
"&pCode=" & Request.Form("pCode") & "&hPhone=" & Request.Form("hPhone") & "&wPhone=" & Request.Form("wPhone"))
End If
Hopefully that makes sense to anyone looking at my question and now my answer.