Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retain DIV Visibility After PostBack 1

Status
Not open for further replies.

SgtJarrow

Programmer
Apr 12, 2002
2,937
US
ASP is not my forte...I am a Windows programmer by training. But I was asked to create an ASP application and have run into a problem. I have been searching for an answer and nothing I have found works for me.

I have a web page with two DIVs on it. They need to occupy the same place and I am using two radio buttons to control which is displayed. That all works fine.

After entering some info and hitting a Search button, the data is processed correctly, but during PostBack the default DIV (productselectiondiv) is visible again. If the user had selected the alternate DIV, I need that to be retained during PostBack.

I have tried Page.ClientScript.RegisterStartupScript() stuff, a hidden value field and javascript attached to the windows.onload and just can't get anythign working.

Here's what I think is relative code...This is unmodified from any of my trys. If you need more, please let me know. Any suggestions??? Thanks.

Code:
aspx.vb File
Page_Load
            Me.rdbProducts.Attributes.Add("onclick", "showProducts()")
            Me.rdbRetailers.Attributes.Add("onclick", "hideProducts()")

aspx File
    <script type="text/javascript">
    <!--
        function showProducts() {
            document.getElementById('productsselectiondiv').style.display = "block";
            document.getElementById('retailersselectiondiv').style.display = "none";
        }
        function hideProducts() {
            document.getElementById('productsselectiondiv').style.display = "none";
            document.getElementById('retailersselectiondiv').style.display = "block";
        }
    // -->
    </script>

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
What is the HTML markup?

I would use a multiview control and have 2 view. You would set the appropriate view visible based on your radio button selection
 
Spot on! As I said, ASP is not my strongpoint. I had not used the MultiView before (and didn't even know about it). Quick web searching and some triel and error and I made this work exactly as I needed. THANKS!

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top