• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

how to maintain the last selected item in select box in page load using asp.net

Hi guys
i need to maintain the last selected item in select boxes either by asp.net session or javascript . im submitting the form to itself ...and when it submit to itself the page execute some server side code and reload the page ....because of that reloading i lost the last selection in select boxes. Any suggestions........?
Below is the form:

<form name="frm" action="mygroup.aspx" method="post" onSubmit="return submitform();">
<br />
<br />
<table width="100%" border="0" cellspacing="1" cellpadding="1">
      <tr>
        <td>
            <select name="gateway_dep" onchange="refreshDest()">
          <option></option>
        </select>
            </td>
      </tr>
      <tr>
        <td>
            <select name="dest_dep" onchange="destchanged()">
          <option></option>
        </select>
            </td>
      </tr>
      <tr>
              <td>
                  <select name="no_hotel">
                      <option></option>
              </select>
            </td>
       </tr>
        <tr>
        <td>
            <select name="duration">
          <option value="7">1 Week</option>
              <option value="14">2 Weeks</option>
        </select>
            </td>
      </tr>
        <tr>
        <td>
            <input name="age" type="text" />
            </td>
        </tr>
        <tr>
        <td>
              <input name="submit" type="submit" value="Search">
        </td>
        </tr>
    </table>
      <br />
</form>
<form name="form1" runat="server">
<asp:TextBox ID="txt" runat="server" TextMode="MultiLine" Height="300" Width="730" />
</form>

select box get populated using client side javascript


0
shwaqar82
Asked:
shwaqar82
1 Solution
 
davehunt00Commented:
put this in your page_load:

if not Session("ddlmyDDL") is nothing then
   ddlmyDDL.SelectedIndex = Session("ddlmyDDL")
end if

and in the ddlmyDDL_SelectedIndexChnaged
Session("ddlmyDDL") = ddlmyDDL.SelectedIndex

hth
davehunt00
0
 
shwaqar82Author Commented:
as i mentioned above ...this is not asp.net controls
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now