Results 1 to 24 of 24

Thread: Make label Visibility False

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Make label Visibility False

    hi All,This is my first thread on this site.I m student. SOmebody told me to join this site. I hope that this site also helped me,as it others.

    Code:
     protected void Page_Load(object sender, EventArgs e)
        {
            Button3.Attributes.Add("onclick", "disable()");
        }
    
    function disable()
        {
        document.getElementById('<&#37;= Label2.ClientID %>').visibility = 'hidden';
                                        OR
        document.getElementById('<%= Label2.ClientID %>').style.display ='none'; 
        }
    I tried both the above code,but none of them is working.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Welcome to the forums!!

    I am sure we will be able to help you!!

    Can you perhaps provide some context as to what exactly you are trying to achieve, and also the errors that you are receiving?

    Both of the approaches that you are using, should do what you want, so I am curious to see what exactly is going wrong.

    Also, can you show the source view of your page for the disable method?

    Gary

  3. #3
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Make label Visibility False

    Your first part is server side code and the second side is client side javascript.
    Output a string from your function disable() that contains your javascript code you need.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Pradeep, this:

    Code:
    document.getElementById('<&#37;= Label2.ClientID %>').visibility = 'hidden';
    Is a combination of client side javascript, with a server side tag to grab the ClientID of the label control.

    This should render the ID of the server side client's id into the javascript, so it is a valid technique, but I was curious to what was actually being rendered to the client.

    Gary

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Make label Visibility False

    Put the function disable() code in the aspx file inside <script> tags and that should work.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  6. #6
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Make label Visibility False

    Code:
    <script language="javascript">
    function disable()
        {
        document.getElementById('<&#37;= Label2.ClientID %>').visibility = 'hidden';
                                        OR
        document.getElementById('<%= Label2.ClientID %>').style.display ='none'; 
        }
    </script>
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    I had assumed that the OP was already doing that, but you could be right...

    hitesh_k, does all the code that you posted in your first post live in the code behind page for your application, or have you combined code from two places?

    Gary

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Make label Visibility False

    I combine the client code and server side code;

    Code:
    <title>Untitled Page</title>
        <script language ="javascript" type ="text/javascript" >
       function disable()
        {
         document.getElementById('<&#37;= Label2.ClientID %>').visibility = 'hidden';
    OR
         document.getElementById('<%= Label2.ClientID %>').style.display ='none'; 
        }
           </script>
    Code:
    protected void Page_Load(object sender, EventArgs e)
        {
            Button3.Attributes.Add("onclick", "disable()");
        }

    I want to make the visiblility false thru JS,but its not working.

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Ok, what you still haven't shown what was asked for.

    What exactly isn't working? Are you getting a javascript error, if so, what is it?

    Also, can you show the source view version of the disable method?

    Gary

  10. #10
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Make label Visibility False

    I think visibility is a member of style.

    Try this:
    Code:
     document.getElementById('<&#37;= Label2.ClientID %>').style.visibility = 'hidden';
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  11. #11

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Make label Visibility False

    Hi both of you.No Error is there.But label is not going to be invisible.Pradeep even i did the change as suggested by you,but its also not working.

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Which browser are you running?

    It may be that a javascript error is being supressed.

    Can you try the following:

    Code:
    <title>Untitled Page</title>
        <script language ="javascript" type ="text/javascript" >
       function disable()
        {
            alert("hi");
        }
           </script>
    Do you get a message box popping up when you click on the button?

    Gary

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Also, you still haven't shown the source of the page? Can you do this?

    Gary

  14. #14
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Make label Visibility False

    Right click your browser output page, select View Source and paste the source here.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  15. #15

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Make label Visibility False

    yes Gep13, alert is coming. I test the code without building the application means i run the code thru F5 option. Pradeep,I m not able to view page source.Because in my pc viruses are there,may be because of that its not opening.

  16. #16
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Okay, let's back up a step here and see what exactly is happening.

    Can you answer the following questions:

    1) What web browser are you using?
    2) What version of Visual Studio are you using?
    3) Are you able to see the alert with the text "hi" in it when you press the button?
    4) What viruses do think you have on your machine?
    5) Do you have any anti-virus software?

    Gary

  17. #17

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Make label Visibility False

    1) IE And Firefox
    2) VS 2005
    3)Yes I m able to see alert.
    4)As Local Settings folder is invisible,When I go to Folder Options- & Check Show Hidden Files And Folders,Even then the hidden folders are not visible.
    5) No I dont have.

  18. #18
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Make label Visibility False

    Quote Originally Posted by hitesh_k View Post
    yes Gep13, alert is coming. I test the code without building the application means i run the code thru F5 option. Pradeep,I m not able to view page source.Because in my pc viruses are there,may be because of that its not opening.
    Viewing a page source is a very basic thing. If that's being prevented and you suspect a virus on your PC, I suggest you should fix that before programming anything furthur. They might interfere with your programs and you would always be blaming something bad in your code, whether your code is right or wrong.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  19. #19
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    I have to agree with Pradeep here. If you suspect that you have a virus, then you really should try and get this sorted, as who knows what sort of problems this could be causing.

    I would recommend a combination of the following programs:

    1) AVG Free Edition
    2) Zone Alarm Personal
    3) Spyware Blaster
    4) SpyBot Search and Destroy
    5) MalwareBytes

    Everyone has their own preferences, but the above is what I have used in the past, and has worked quite well, and is totally free.

    Gary

  20. #20

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Make label Visibility False

    gep13, I download Zone Alarm. Is it Good?

  21. #21
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    Zone Alarm is a firewall, and in my opinion it is quite good at what it does.

    But, if you have a virus, then this alone will not help you. You would need the other packages as well in order to sort out a virus/spyware problem.

    Gary

  22. #22

    Thread Starter
    Member
    Join Date
    Oct 2009
    Posts
    42

    Re: Make label Visibility False

    I will first format the computer.Then install anti virus,After formatting it does work na?

  23. #23
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Make label Visibility False

    Hey,

    If you have that option, then yes, this would be the best approach.

    Start from a clean system, and then put the software in place to stop any infections.

    Gary

  24. #24
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: Make label Visibility False

    so did the problem got resolved..?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width