?
Solved

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

Posted on 2007-10-02
2
Medium Priority
?
386 Views
Last Modified: 2008-01-09
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
Comment
Question by:shwaqar82
2 Comments
 
LVL 4

Accepted Solution

by:
davehunt00 earned 1000 total points
ID: 20001959
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
 

Author Comment

by:shwaqar82
ID: 20005898
as i mentioned above ...this is not asp.net controls
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

840 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