|
-
Oct 18th, 2009, 01:13 PM
#1
Thread Starter
Member
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('<%= Label2.ClientID %>').visibility = 'hidden';
OR
document.getElementById('<%= Label2.ClientID %>').style.display ='none';
}
I tried both the above code,but none of them is working.
-
Oct 18th, 2009, 01:29 PM
#2
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
-
Oct 18th, 2009, 01:36 PM
#3
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.
-
Oct 18th, 2009, 01:43 PM
#4
Re: Make label Visibility False
Hey,
Pradeep, this:
Code:
document.getElementById('<%= 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
-
Oct 18th, 2009, 01:44 PM
#5
Re: Make label Visibility False
Put the function disable() code in the aspx file inside <script> tags and that should work.
-
Oct 18th, 2009, 01:47 PM
#6
Re: Make label Visibility False
Code:
<script language="javascript">
function disable()
{
document.getElementById('<%= Label2.ClientID %>').visibility = 'hidden';
OR
document.getElementById('<%= Label2.ClientID %>').style.display ='none';
}
</script>
-
Oct 18th, 2009, 01:53 PM
#7
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
-
Oct 18th, 2009, 02:16 PM
#8
Thread Starter
Member
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('<%= 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.
-
Oct 18th, 2009, 02:19 PM
#9
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
-
Oct 18th, 2009, 02:21 PM
#10
Re: Make label Visibility False
I think visibility is a member of style.
Try this:
Code:
document.getElementById('<%= Label2.ClientID %>').style.visibility = 'hidden';
-
Oct 18th, 2009, 02:39 PM
#11
Thread Starter
Member
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.
-
Oct 18th, 2009, 02:55 PM
#12
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
-
Oct 18th, 2009, 02:56 PM
#13
Re: Make label Visibility False
Hey,
Also, you still haven't shown the source of the page? Can you do this?
Gary
-
Oct 18th, 2009, 02:56 PM
#14
Re: Make label Visibility False
Right click your browser output page, select View Source and paste the source here.
-
Oct 18th, 2009, 03:12 PM
#15
Thread Starter
Member
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.
-
Oct 18th, 2009, 03:16 PM
#16
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
-
Oct 18th, 2009, 11:57 PM
#17
Thread Starter
Member
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.
-
Oct 19th, 2009, 01:26 AM
#18
Re: Make label Visibility False
 Originally Posted by hitesh_k
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.
-
Oct 19th, 2009, 01:33 AM
#19
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
-
Oct 19th, 2009, 11:52 AM
#20
Thread Starter
Member
Re: Make label Visibility False
gep13, I download Zone Alarm. Is it Good?
-
Oct 19th, 2009, 11:54 AM
#21
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
-
Oct 19th, 2009, 11:57 AM
#22
Thread Starter
Member
Re: Make label Visibility False
I will first format the computer.Then install anti virus,After formatting it does work na?
-
Oct 19th, 2009, 12:08 PM
#23
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
-
Oct 22nd, 2009, 06:36 AM
#24
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|