Solved

Preserve value of controls in .ASPX

Posted on 2011-02-20
3
234 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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 …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

14 Experts available now in Live!

Get 1:1 Help Now