Results 1 to 5 of 5

Thread: Undeclared Control in ASP

  1. #1

    Thread Starter
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Question Undeclared Control in ASP

    Assume it Connects to the DB and here is part if the Body:
    VB Code:
    1. While Not rs.EOF          ' rs is the recordset
    2.     Response.Write("<tr>")
    3.     Response.Write("<td align='left'><i>" & rs.Fields(0).Value & "</i></td>")
    4.     Response.Write("<td align='left'>" & rs.Fields(1).Value & "</td>")
    5.     Response.Write("</tr>")
    6.     CountryValueList &= "<option value = " & rs.Fields(1).Value & ">" & rs.Fields(0).Value & "</option>"
    7.     rs.MoveNext
    8.     End While
    9.     response.write("</table>")
    10.     Response.Write("<br><h4 align = 'center'><SELECT name='CarValue' id='ZarValue'>" & CountryValueList & "</SELECT>")
    11.     DatabaseConnection.close
    12. 'If (Request.Form("btnCalculateRate") = "Calculate Rate") Then
    13.     'button was pressed
    14.     'Else
    15.     'Session.Abandon
    16. 'End If
    17.     Response.Write("<br><h4 align = 'center'>" & CarValue.selectedindex.value & ")
    18. Response.Write("<br><input type='submit' name='btnCalculateRate' value='Calculate Rate'/>

    CarValue is the name assigned to the Combobox.
    CountryValueList is the name of the countries and the value for each Country is an ID for Example:
    South Africa is the Item displayed, its hidden value is 0.88 for example
    The problem is the line:
    Response.Write("<br><h4 align = 'center'>" & CarValue.selectedindex.value & ") gives the error saying CarValue is undeclared. I also would Like the Code where if I click Sumit it would take the Current Selected Country in the ComboBox, then Display it in a Label. That is what I Am trying to do in the If Statements:
    VB Code:
    1. 'If (Request.Form("btnCalculateRate") = "Calculate Rate") Then
    2.     'button was pressed
    3.     'Else
    4.     'Session.Abandon
    5. 'End If


    Thanks
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Undeclared Control in ASP

    You're mixing up two things. ASP script doesn't know of the <SELECT> element. To retrieve the value selected from the combobox, use Request.Form() or Request.QueryString().

    The same applies for displaying it in a label. Retrieve the value, then write it out.

  3. #3

    Thread Starter
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Re: Undeclared Control in ASP

    What you Mean? That Above puts the Data into the Combo Box.
    Do I need to Retrieve it using response.write?

    Here is the response.write I use:
    Response.Write("<br><h4 align = 'center'>" & CarValue.selectedindex.value & ")

    in the select statement doesnt name='carvalue' declare it right
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Undeclared Control in ASP

    No it doesn't. They are separate. ASP 3.0 cannot 'see' carvalue. It only knows what has been submitted to it. Which is why you need to use Request()

  5. #5

    Thread Starter
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Re: Undeclared Control in ASP

    Please Give an Example, in the Above Example
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width