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 4597440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:15:27+00:00 2026-05-21T23:15:27+00:00

I want to do this but in asp.net. How would I write this in

  • 0

I want to do this but in asp.net. How would I write this in asp.net/the code behind? I already have

protected void chkBox_CheckedChanged(object sender, EventArgs e)
{
    if (chkBox.Checked){}
    else{}
}

with

<asp:Checkbox ID="chkBox" AutoPostBack="True" runat="server"
      onCheckedChanged="chkBox_CheckedChanged" />

so I need help filling in the rest. Seriously though, thanks so much!

UPDATE 2:
This method works but the message/div doesn’t show long enough to read the text. Found out it’s due to AutoPostBack="true". How do I call the event after the AutoPostBack is done (I’m guessing that’s what I need to solve the problem)?

function displayDiv(checkbox) {
            if (checkbox.checked) {
                $("#message1").stop(true, true).show().fadeOut(10000);
                $("#message2").hide();
            }
            else {
                $("#message1").stop(true, true).hide();
                $("#message2").stop(true, true).show().fadeOut(10000);
            }
        }


<asp:CheckBox ID="chkNotifyMe" AutoPostBack="True" runat="server"   OnCheckedChanged="chkNotifyMe_CheckedChanged" onclick="displayDiv(this)" /> 
<div id="message1" class="message" ><span>Successfully <small></small></span></div><br />
<div id="message2" class="message" ><span>Removed<small></small></span></div>

(all css is the same)

So close I can taste it 😀 Thanks again!

FINAL SOLUTION
Alright I added this to my page to call the AutoPostBack through jQuery and after it posts, to display my message

function pageLoad() {
            <%# autoLaunchJS %>
             $("#chkNotifyMe").click(chkNotifyMe_clicked);
        }
function chkNotifyMe_clicked(){
    var add = $get("chkNotifyMe").checked == true;
    PageMethods.WishList(add, <%#ID%>, OnSucceeded, OnFailed);
    }

    function OnSucceeded(){
        refreshStartPage();
        if($get("chkNotifyMe").checked){
                    $("#messageSuccess").stop(true, true).show().fadeOut(5000);
                    $("#messageRemove").hide();
        }
        else{
            $("#messageSuccess").stop(true, true).hide();
            $("#messageRemove").stop(true, true).show().fadeOut(5000);
            }
    }
  • 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-21T23:15:27+00:00Added an answer on May 21, 2026 at 11:15 pm

    You can have client code and server logic at the same time for a server control. If the display of that div is all you are planning to do, then it’s pure view logic and it definitely something to do with javascript and posting back to server and refreshing the view would be wasteful.

    You can slightly change your javascript to do this

    function displayDiv(checkBox) {
            if (checkBox.checked) {
                                $("#message1").stop(true,true).show().fadeOut(4000);
                $("#message2").hide();
            }
            else {
                $("#message1").stop(true,true).hide();
                $("#message2").stop(true,true).show().fadeOut(4000);
            }
    
        }
    

    and

    <asp:Checkbox ID="chkBox" AutoPostBack="True" runat="server"
          onCheckedChanged="chkBox_CheckedChanged" onclick="displayDiv(this)" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing something like this- http://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_video_js_prop but I want to replace the buttons
I want to implement this view But I have one question: The text which
I want to create maintainable code, but this inheritance situation is causing me problems.
I am writing code in ASP.NET and I am new at it. I have
I have some asp.net code that populates the fields in a LINQ to SQL
If I have a single label on my ASP.NET (2.0) page, and I want
I've Googled for this but must be using the wrong keywords. Basically I want
hello i am little new to all this but i want to know that:
http://subzerostudio.com/temp/verticalscroller/temp.html I want this scroll to effect the div#container instead of the body,html but
I am appending new data - $('#posts').append(data); But I want this new data to

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.