Solved

Preserve value of controls in .ASPX

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RLDC Reporting in Visual studio 11 30
Open a link in vb.net 2 16
Finding Events logs for IIS website that restarts 2 14
VB.Net - String Manipulation Scenario 2 25
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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