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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:01:44+00:00 2026-06-18T00:01:44+00:00

I am working on a webforms project using c#/aspx/jquery. I’m not sure where to

  • 0

I am working on a webforms project using c#/aspx/jquery. I’m not sure where to handle my Onclick. Both options (doing it in C# or jquery) seem feasible. Which would be better practice?

Here is the scenario:

I want to build a checkbox which will toggle a textbox's textmode, altering it between Password and SingleLine.

Currently, I have this following code for my markup since I am currently handling it in C#:

<asp:Checkbox ID="CheckBox1" OnCheckedChanged="CheckBox1_OnCheckedChanged"/>

The code:

protected virtual void OnCheckedChange(EventArgs e)
{
     If (CheckBox1.TextMode == TextMode.Password)
          CheckBox1.TextMode = TextMode.SingleLine;
     else
          CheckBox1.TextMode = TextMode.Password;
}

The use case of this is: A user is entering his password. On the same page, he may choose to keep the password hidden or not by checking the checkbox.

  • 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-06-18T00:01:45+00:00Added an answer on June 18, 2026 at 12:01 am

    Which would be better practice?

    What is your functional requirement?

    • Setting this in C# on the asp.net code behind, you will need a post-back to make it work. This means the page will refresh and the text box will change.
    • On the client (JS/JQuery) the page will not refresh.

    Now you evaluate the work required vs the quality you need. (If you want a nice user experience and are ok with writing JS put it in JS, if you’re strapped for time and are ok with the refresh then do it on asp.net).

    I’m trying to answer your question in general sense about HOW such a decision (in my humble opinion) should be made. Realistically this is very simple to implement in javascript and your should do it there.


    Now for the code (I assume you know how to put it in asp.net code behind so I’m going to write the JS approach):

    Html:

    My Password: <input type="password" id="mytext" /> <br />
    Hide Chars : <input id="passChk" type="checkbox" checked="true" />
    

    Javascript:

    $(function() {
        $("#passChk").change(function(){
            if(this.checked) {
                $("#mytext").attr("type","password");
            } else {
                $("#mytext").attr("type","text");
            }
        });
    });
    

    See it running here: http://jsfiddle.net/rC5NW/2/

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

Sidebar

Related Questions

I recently began working on a large ASP.NET WebForms project. The project was using
I am working on a .Net WebForms project and am using UpdatePanels in order
I'm using Callback, on a asp.net webforms project. When clicked button, it is working
I'm working with an ASP.NET MVC 2 project using a classic ASP.NET WebForm wired
I have a project I'm working on in webforms and I've run into a
Previous working asp.net webforms app now throws this error: System.MissingMethodException: Method not found The
I'm working on a moderately sized WebForms project. Due to the peculiarities of management
Currently I'm working on Web project that is built using ASP.NET Web Forms. We
I currently have pagination working in my MVC 3 project using the PagedList library
The project I am working on was a project that was originally WebForms and

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.