Solved

Preserve value of controls in .ASPX

Posted on 2011-02-20
3
233 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now