Solved

Custom ASP.Net Server Control Issue

Posted on 2008-10-02
5
204 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
  • 3
5 Comments
 
LVL 20

Expert Comment

by:informaniac
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
This does the trick ... Thx :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now