Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Save CheckBox state after postback

Posted on 2013-06-11
5
Medium Priority
?
2,748 Views
Last Modified: 2013-07-18
I think I'm making this much harder than it is but I'm having a time figuring it out.

I have a page that posts back with query strings in the URL and every time this happens my checkboxes clear to their default state. I've mucked around continuously using ViewState['variable'] = lbl.Text to collect the value of a label in order to populate the state of the checkboxes and have gottent nowhere. Every page i see online seems to be overcomplicating what I need it to do. Just need to save the state of a single checkbox or a label in order to pass a value to the checkbox.
0
Comment
Question by:BigDeer
[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 4

Accepted Solution

by:
bepsoccer1 earned 2000 total points
ID: 39239361
try this
protected override void LoadViewState(object savedState)
{
    base.LoadViewState(savedState);

    if (ViewState["Checked"] != null)
        checked = (bool)ViewState["Checked"];
}

protected override object SaveViewState()
{
    ViewState["Checked"] = checked;

    return base.SaveViewState();
}

Open in new window

0
 
LVL 3

Author Comment

by:BigDeer
ID: 39239367
Does this work for the entire document? Anything else I need to do to get this to talk to my checkboxes?
0
 
LVL 3

Author Comment

by:BigDeer
ID: 39336506
I was able to resolve this issue with update panels. Thanks.
0
 
LVL 3

Author Closing Comment

by:BigDeer
ID: 39336509
Resolved with update panels. Thanks.
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Six Sigma Control Plans
Progress

670 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