Solved

Custom ASP.Net Server Control Issue

Posted on 2008-10-02
5
213 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
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 500 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON  parse help 7 40
bound data table problem 2 33
Open a link in vb.net 2 16
JSON Deserialize issue 6 26
Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
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…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

830 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