?
Solved

Custom ASP.Net Server Control Issue

Posted on 2008-10-02
5
Medium Priority
?
217 Views
Last Modified: 2013-11-07
I have a asp.net server control that I have written, that display a ordered or unordered list that can contain a number of list items. The developer can determine the through properties to set the number of initial items to display when the controls are invoked the firstime on the web form. For example, there are 10 items, the developer says 5 should show and 5 should remain hidden.

When rendered, there are two buttons that allow the vistor to make these items appear or hide items one click at a time buy the use of client side JavaScript.

The issue is, when the page refreshes, because of the current design, the controls revert back to their initial items to display property.

I'm struggling with the best way to handle some sort of viewstate that the pages remembers the last number of items the user had exposed before the page refreshed or when they return back to it. The other thing to consider is that the list can also be a static text or even a hyperlinked list of items.

So I need to figure out how to communicate the present items count back to the control so when it redisplays the same number.

I've thought about a hidden field that the JavaScript routine would update (+ or -), cookies ro some other method. I don't believe there is anyway to use the viewstate for this, but could be wrong.

Any thoughts on how this should be handled in the real world asp.net server control?
0
Comment
Question by:WebGeeksUnlimited
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 22631465
When u r updating using javascript the best would be to update a hidden field...

And fetch the details from the hidden field when the page posts back
0
 
LVL 1

Author Comment

by:WebGeeksUnlimited
ID: 22636106
I was thinking of that, but that would only work if you post back to the same page. It's possible that the link could take you to a different page on the site, which at that point, you would loose that current items displayed count.
 
0
 
LVL 7

Accepted Solution

by:
ASPSQLServerCOM earned 2000 total points
ID: 22638022
http://www.eggheadcafe.com/articles/20030625.asp

you have to use
protected override object SaveViewState()
and protected override void LoadViewState(object savedState)
0
 
LVL 1

Author Comment

by:WebGeeksUnlimited
ID: 22639455
I wasn't sure that this would work originally, but I'll read the article over the weekend and give it a try.
0
 
LVL 1

Author Closing Comment

by:WebGeeksUnlimited
ID: 31502645
This does the trick ... Thx :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

752 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