passing parameters discretely

Discussion in 'C#' started by kmalak, Oct 5, 2006.

  1. #1
    Hi,
    Current situation: I have an unordered html list with list items calling an asp (with an url parameter), look at the code below
    Desired situation: I have an unordered html list with list items calling an asp (without url parameter, instead passing parameter in a different way, maybe via the session variable).
    Question: how to pass selected list item value/index to an asp (without url parameters)?

    Thanks

    <% LocalArray = Session("JaarArr") %>
    <ul class="secondair-menu" id="YearList">
      <% For i = 0 to cInt(Session("Aantaljaar"))-1 %>
        <li><a href="cumulatief.asp?jaar=<%=localArray(i)%>"><script   
            language=Javascript>formatjaar(<%=localArray(i)%>)</script></a></li>
      <% Next %>
    </ul>
    Code (markup):
     
    kmalak, Oct 5, 2006 IP
  2. DangerMouse

    DangerMouse Peon

    Messages:
    275
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The only way I know of passing values outside of a URL string in ASP is by posting the values to the destination page, like so:

    ### start page ###
    
    <% LocalArray = Session("JaarArr") %>
    <form id="formx" method="post" action="cumulatief.asp">
    <select id="YearList">
      <% For i = 0 to cInt(Session("Aantaljaar"))-1 %>
        <option value="<%=localArray(i)%>"><%=localArray(i)%>)</option>
      <% Next %>
    </select>
    <input type="submit" value="submit" />
    </form>
    
    Code (markup):
    ### cumulatief.asp ###
    
    <%
    If Request.Form("YearList") <> "" Then
    'whatever other processing you want to do here...
    Session("SelectedValue") = Request.Form("YearList")
    End If
    %>
    
    Code (markup):
    You could make it a bit smoother by using javascript to submit the form on the starting page (onchange="document.formx.submit();") not perfect but may be worth looking into as a workaround.

    Good luck with it!
     
    DangerMouse, Oct 9, 2006 IP