Solved

Preserve value of controls in .ASPX

Posted on 2011-02-20
3
237 Views
Last Modified: 2012-06-27
I have been tinkering with this forever and now I just completely messed it up.  My commission does not display when i submit the form and the listbox isn't displaying properly now.  Can anybody help me reorganize my code?
<form id='frmShowCommSingleDocKeepState' action='afShowCommSingleDocKeepState.aspx' method='get' >
      <div>
 
      <%  
        Dim strSale As String
        Dim dblSale As Double
        Dim strRegion As String
          Dim dblComm As Double
          Dim E As Double = 0.1
          Dim W As Double = 0.2
          
          strSale = Request.QueryString("txtSale")
          If strSale = "" Then
              Response.Write("Monthly Sale")
              Response.Write("<input id='txtSale' type='text' name='txtSale'/><br /><br />")
              Response.Write("Select your Sales Region: ")
              Response.Write("<select id='lstRegion' name='lstRegion' size='2'>")
              Response.Write("<option value='E'> Eastern</option>")
              Response.Write("<option value='W'> Western</option>")
              Response.Write("</select><br /><br />")
              Response.Write("<input id='btnShowCommission' type='submit' value='Show Commission' /><hr /><br />")

          Else
              strRegion = Request.QueryString("lstRegion")
              dblSale = CType(strSale, Double)
              Response.Write("Monthly Sale")
              Response.Write("<input id='txtSale' type='text' name='txtsale' value=  ")
              Response.Write("'" & strSale & " ' " & "/><br /><br />")
              Response.Write("Select your Sales Region: ")
              Response.Write("<select id='lstRegion' name='lstRegion' size='2'>")
              If strRegion = "E" Then
                  Response.Write("<option value='E' selected='selected'> Eastern</option>")
              Else
                  Response.Write("<option value='E'>Eastern</option>")
                  Response.Write("<option value='W' selected ='selected'> Western</option>")
              End If

    
              Select Case strRegion
                  Case "E"
                      dblComm = dblSale * E
                      Response.Write("Your Commission is: " & FormatCurrency(dblComm))
                  Case "W"
                      dblComm = dblSale * W
                      Response.Write("Your Commission is: " & FormatCurrency(dblComm))
              End Select
          End If
          
        %>
   </div>
  </form>

Open in new window

0
Comment
Question by:networknoobaf24
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34940909
The reason it is not displaying is because you haven't closed the "select" tag. Add the following line just before the "Select Case strRegion" line:
Response.Write("</select>")

Open in new window

0
 

Author Comment

by:networknoobaf24
ID: 34941141
wow, that was a simple mistake.  ok, now i cant figure out why "Western" does not display if i choose "Eastern" once i hit submit.  Any ideas?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34941193
That's down to your "If" block. Notice that you are check for "E" and then only outputting a single "option", but outputting two options in the "Else" part.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# MVC Insert Multiple Row into DB 2 61
Name Space error VS2015 1 35
asp.net figure out error 3 21
asp.net web app 3 19
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

762 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