Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Preserve value of controls in .ASPX

Posted on 2011-02-20
3
Medium Priority
?
240 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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