ASCX controls ASP.NET - Cannot find Visible method - asp.net

In a particular page i have a ascx control which contains a table.
Now I want to set this control visible/invisible but the visible method is not detected by the intellisense.
The only methods are 1)Equals and 2) ReferenceEquals
Main Page
<VPM:VotingPolls Runat="server"></VPM:VotingPolls>
Thanks

Thanks it has been solved
The problem was that no id was set.
<VPM:VotingPolls ID="VPS" Runat="server"></VPM:VotingPolls>
then
VPS.Visible=True/False

Make sure that your markup is well formed and that there is a proper header line for the ascx control on your page. 99% of the time, if intellisense doesn't work, it means that something is wrong with the code and/or markup.

Sometimes intellisense doesn't display available attributes. But the visible attribute will be available. So just type visible='true/false'. That should work.

Related

I get a NullReferenceException when I use FindControl to find controls in either master or content pages

I am trying to create reversible themes in ASP.NET. I can successfully change themes using a dropdown list, but I am running into problems changing SkinID's and generic HTML controls (which are all div's except for the body tag) programmatically. I moved all my attribute- and skin-changing code to the PreInit method of my Base Page. Now I get a NullReferenceException when I run the page. I thought this code was supposed to use the existing controls it is supposedly pointing to. What am I missing or doing wrong?
Here is my code:
The PreInit event is probably too early in the page lifecycle to look for controls with FindControl. You're also doing your declarations outside of the event. That may have something to do with your null reference as well. I'd see if you can change it to look later in the lifecycle. This may be helpful if you haven't already seen it: http://msdn.microsoft.com/en-us/library/ms178472.aspx

Linking to ascx file

I am utilizing controls in my asp.net application. I have a register tag the source of which needs to be dynamic. I am using the line below which functions correctly when the full path is specified but when I change it to the variable I get a parser error. Any idea how I can go about doing this?
Thanks
It might be better to use Load Control from the code behind of the aspx page.
If I'm understanding you correctly — you can't use a variable in those directives (Page, Register, etc). They have to be constant expressions.
However, it is possible to dynamically load ASCX controls. You would have to do this in code, though, and it would not involve the Register tag.

making control in user control visible=false on mouse over

More
I have this datalist in a user control i want when i keep mouse over "More", it should be invisible. it is working on .aspx page not on user control. How to do this. This control is placed on master page.
Please Help.
Probably it will be an issue with getElementById. In a naming container you cannot get the element by simply giving its id. You have to use ClientID to get the generated id of the element at runtime.
Something like
document.getElementById ( "<%= DataList2.ClientID %>");
See Control.ClientID Property
and
Control ID Naming in Content Pages
I would agree that it's probably an issue with trying to get the id of the element since the element's id changes at runtime when you put it inside a user control. You can run your code then do a view source in the browser and see exactly what the id is generating to at runtime.
Have you tried debugging the javascript mover() and mout() function? I am guessing you are looking for elements with the wrong id's since the id's are probably different inside a user control.

List of themeable / skinable properties for ASP.NET controls?

Does anyone know how or where I can find a list of properties that can be defined in a skin file for standard ASP.NET controls?
Thanks
I believe that every property is, by default, Themeable. But, a number of properties are marked with the Themeable(false) attribute. For example, an asp:Button has its OnClientClick property marked Themeable(false).
Don't know how to get this list up front though. You'll get an error when you view a page and a Skin file tries to set a non-Themeable property.
In my experience, you can set all properties of all controls. I just made a small test, I found that it's even possible to define the items to be displayed in a ListBox in the skin file.

should every element with runat=server have an id attribute?

I have inherited an asp.net website to maintain
when looking at the aspx page, almost every element with runat=server don't have id attribute defined.
should I go through every element and add one?
Unless the control is inside a repeating control it should have a unique ID attribute assigned to it. Here is some MSDN documentation on how to add server controls to an ASPX page.
You only need to give them ids if you're going to reference them in your code. If you're not referencing them at all you might wonder why they are .net controls and not just html elements.
ASP will assign an unique ID if you don't. Sometimes I don't bother when I won't be manipulating it.
Speaking specifically to your situation of having inherited an app, it's not a pressing issue. ASP.NET will automatically generate IDs for them at runtime.
Generally, aiming to replace those controls with HTML elements (as someone else mentioned) is a good idea. Do be careful though. Just because an element doesn't have an ID doesn't mean it's not being referenced on the server side at runtime.
You don't need to set IDs to the controls you don't reference. ASP.NET will do it for you. That's it.
This does NOT automatically mean, they can be replaced with HTML controls. Having a control with runat="server" without having an ID set is perfectly reasonable.
e.g.:
<asp:ListView runat="server" DataSourceID="someDataSource">

Resources