Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 219355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:50:13+00:00 2026-05-11T18:50:13+00:00

I have a simple task – to change page link on checkbox state change

  • 0

I have a simple task – to change page link on checkbox state change – but I’m new to ASP.NET and have some trouble.

I can do the same using HtmlControl and JavaScript:

<script type="text/javascript" language="javascript">
  function checkbox_onChanged(checked) {
    if (checked) {
      document.location = '?type=request_in&show=all';
    }
    else {
      document.location = '?type=request_in&show=unapproved';
    }
  }

  function checkbox_onLoad(checkbox) {
    checkbox.checked = true;
  }
</script>

<form action="" method="get">
<input type="checkbox" name="checkbox"
  onload="checkbox_onLoad(this)"
  onchange="checkbox_onChanged(this.checked)" />Show all
</form>

but I want to hide it from users. So I do:

<asp:CheckBox runat="server" ID="check" 
  OnCheckedChanged="check_CheckedChanged"
  AutoPostBack="True" Text="Show all" />

protected void check_CheckedChanged(object sender, EventArgs e)
{
  Response.Redirect(String.Format("{0}?type=request_in&show={1}", Request.Path, 
  checkViewRequestIn.Checked ? "all" : "unapproved"));
}

protected void Page_Load(object sender, EventArgs e)
{
  var show = Request["show"];
  if (!String.IsNullOrEmpty(show) && String.Equals(show, "all"))
  {
    checkViewRequestIn.Checked = true;
  }
}

But it seems that check state change on load raises the event again and checkbox becomes checked always!

Ans another question – is there any other way to redirect to the same page without giving it’s filename? I mean like in JavaScript – only giving variables needed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:50:13+00:00Added an answer on May 11, 2026 at 6:50 pm

    You can call your client-side ‘checkbox_onChanged’ from the ASP.NET checkbox, just add the ‘onchange’ from the Page_Load, e.g:

    protected void Page_Load(object sender, EventArgs e)
    {
       check.Attributes["onchange"] = "checkbox_onChanged(this.checked)";
    }
    

    View source and you’ll see what is happening in the HTML..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple task, but I cannot find any solution. I have
This is a very simple task in every language I have ever used, but
That's a simple task in ASP.NET WebForms:If you want to show/hide a control all
I have a simple task of adding a paragraph that has some formatted text
I'm new to javascript and have a simple task. I have an array values
I have to do a simple task, but I don't know how to do
Probably a common problem, but anyway: Let's say I have a simple entity Task
I have a simple task to accomplish, but I am not sure what is
This should be a simple task, but I have seen several attempts on how
I have a possibly simple task ahead of me, but my RegEx skills are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.