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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:59:45+00:00 2026-06-18T05:59:45+00:00

I am using asp.net c# and what I would like to achieve is when

  • 0

I am using asp.net c# and what I would like to achieve is when the user clicks within a text box on the form to hide a label (I am using this label for some feedback).

I was trying something like the following code but the label is never hided:

hiddenMsg.Visible = true;
.
.
.

private void compTxt_TextChanged(object sender, EventArgs e)
{
    if (!IsPostBack)
        {
            hiddenMsg.Visible = false;
        }
}

In my aspx file I have the following:

<asp:TextBox ID="compTxt" runat="server" TabIndex='11' AutoPostBack="true" ontextchanged="compTxt_TextChanged" ></asp:TextBox>

[Updated my question]

I am using Javascript to achieve my goal and also I am using style.display attribute in JS instead of Visible = false in order to achieve that, however I am not sure about the method I am using in asp:TextBox, Could anyone help me about how call a JavaScript method from a asp:TextBox ?

function hideMsgs() {
      document.getElementById('<%= hiddenMsg.ClientID %>').style.display = 'none';
}  

<asp:Label ID="hiddenMsg" runat="server" Text="Successfully Saved" style="display:inherit;"/>


<asp:TextBox ID="compTxt" runat="server" TabIndex='11' OnClientClick="hideMsgs()"/>
  • 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-18T05:59:46+00:00Added an answer on June 18, 2026 at 5:59 am

    Get rid of the IsPostBack check, it will always be a postback.

    private void compTxt_TextChanged(object sender, EventArgs e)
    {
        hiddenMsg.Visible = false;
    }
    

    For a client side solution, in your page load:

    protected void Page_Load(object sender, EventArgs e)
    {
        compTxt.Attributes.Add("onclick", "document.getElementById('hiddenMsg').style.display = 'none';");
    }
    

    If you are using a Master Page in your project use this line instead in your page load:

    compTxt.Attributes.Add("onclick", "document.getElementById('" + hiddenMsg.ClientID + "').style.display = 'none';");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET MVC and would like to get Model information for use within
I am using ASP.NET MVC 3 TextBoxFor in a form and would like to
I would like to know about regular expression and text validators using ASP.NET. Do
Using ASP.Net, I have a server control for which i would like to add
I am designing a web application using the ASP.net MVC framework. I would like
Using log4net we would like to log all calls to our ASP.NET MVC controller
I would like to know the version of ASP.NET supports using Windows AppFabric caching
I'm using jQuery validation in ASP.net MVC. I would like to show validation summary
I have this ASP.NET page which I would like to print. What I am
Using ASP.NET with C#, I would like to load the content of another page

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.