Finding the definition of an object in a VB web-user-control - vb.net

I have an ascx.vb file with a function that starts off like this:
Sub buildlist()
repcaldatelist.Visible = True
...
End Sub
I'm just trying to figure out what repcaldatelist is. When I use VS's "Go To Definition", it gives me a popup saying "The definition of the object is hidden." Using "Go To Implementation" does nothing.
I see the corresponding .ascx file with this line:
<asp:repeater ID="repcaldatelist" runat="server">
and I see how repcaldatelist is databound to it, so that page can display its data.
But what I'm trying to understand is, where does repcaldatelist come from? I want to see where it's initialized and what its type is.
I know this is probably really basic but I'm new to VB / Web User Controls and haven't had any luck searching for this online thus far. Please enlighten me.

ID="repcaldatelist" means that's the ID of the Repeater control. So in your .vb file, repcaldatelist is an object of type Repeater - the ID in the ascx/html translates into a variable name in the VB. If you hover over the variable in the .vb file in Visual Studio it should tell you the type as well.
Go To Definition / Implementation don't work because the Repeater class is part of the .NET framework, and it's closed-source - just a DLL on your machine. Therefore there's no source code or definition you can view. You just have access to its public API as defined by the docs (and should be available in intellisense as well).

Related

VB in Visual Studio Adding a class module will it have access for the form.vb I've built?

Hello thanks for reading my question, I've build a user form with controls to control equipment via RS232 and USB. I've also added a separate class module "class.vb" to hold miscellaneous functions like writing to an ini file.
When I'm in the code section of the Form.vb and I type txb for text boxes that I have in the form visual studio pops up a nice list of all things in the form that start with txb.
However, when I do the same thing in my class.vb it does not do this and even if I type the whole thing such as txbModulation and then add the dot after it does not come up with the list of properties.
Does the class.vb have access to Form1.vb controls?
When I'm in the code section of the Form.vb and I type txb for text
boxes that I have in the form visual studio pops up a nice list of all
things in the form that start with txb.
This is because when you start typing a variable name, Visual Studio starts looking for a match. It looks in block scope first (a for or while loop maybe), then at local (function/sub) scope, and finally at class level (a form is a class). It will also look for any matches in Modules if you have them. See Scope in Visual Basic for more info.
Since the Form and your INI Class are different, they cannot see each other unless you pass references or somehow pass values via parameters to subs/functions.

How to create nested user controls in VB.net?

I have the following classes in my vb.net application:
Form1
Usercontrol1
LnkLabel
Usercontrol1 is a user control , and doesnt contain any extra code. LnkLabel is a class that inherits Forms.Label. Its code is goven below:
Public class LnkLabel
Inherits Label
Sub clk handles me.click
Process.start(text)
End sub
End class
When I add an Instance of LnkLabel to usercontrol1, i get an error "type LnkLabel is not defined"
There are three instances of the error in uc1.designer.vb.How can I solve these Errors?
Note:
Visual Studio 2010
.Net FW 3.5
Edit:
The usercontrol1 donot contain any code that might be causing the error. It is just a new usercontrol added to the project.
LnkLabel is added to UC1 by the designer, not by using code at runtime.
The class name is LnkLabel, and not "LinkLabel".
I find that the easiest way to resolve this type of issue is to open the Designer.vb file directly.
To do this, choose Show All Files from the Project menu, then expand UserControl2. Double-click on the UserControl2.Designer.vb file.
You should also be able to get there by double-clicking on the error in the compile errors list.
Once there, search for the definition of UserControl1 or uc1, whatever it may be called (ensure you are in the type definition area, not the property assignment area).
Looking at the definition may give you an instant clue as to the problem (is it in the wrong namespace; did the name of the user control change after you created it, but the change was not propagated to this form; etc).
If it is not obvious what the issue is, use VS intellisense to help you get the right class. I usually clear the previous type definition and start typing the name I know it should be (i.e. UserControl), then select the appropriate value from Intellisense.
Selecting a different class (or correcting the class selection) will require a change to the control instatiation code and may also require a change to some of the properties (I usually just remove the properties I am unsure of and update the control directly in the designer).
Before you switch back to the designer, ensure that you save your changes and, if possible, compile the app.

VB.NET UserControl

I am trying to create a UserControl in VB.net, under VS2010. I have the code for the UserControl and I would like to add it to a form. My problem is that, according to every book and forum I have seen, after I build the UserControl, it should show up in the Toolbox. It doesn't. I even downloaded code from a book, the code executes perfectly, but their TrafficLight control doesn't go in the Toolbox (even though the book says it should - and that the only way to set its properties and to add it to the form is through the Control properties). I have tried to add the control to the form manually, by declaring it
Dim myObj As New SomeClass.SomeControl
and in the Designer.vb, identical with the buttons on the form:
Friend WithEvents myObj As SomeClass.SomeControl
With both, I get an error saying
'myObj' is already declared as 'Friend WithEvents myObj As SomeControl' in this class.
And either way, I get an error when I try to look at the design:
Could not find type 'SomeClass.SomeControl'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure the project has been successfully built using settings for your current platform or AnyCPU.
The control by itself builds and shows up in design view (not in the Toolbox though, even though it Imports System.ComponentModel and Inherits System.Windows.Forms.UserControl and... what else ? I tried to build it in a separate project, to see if I creating a separate dll will make a difference, though I really want it in the same project.
Please help ! (BTW I have reinstalled VS2010 and it did no good)
Thank you.
Look in Tools / Options / Windows Forms Designer and set "AutoToolboxPopulate" to True (but note that this can take a noticeable amount of time if you haver many (i.e. dozens) of user controls.

Public properties from another class in vb.net

I've tried searching... a lot for the answer, but as I'm not too sure what exactly I'm trying to do I can't seem to find anything.
I'm trying to write a dll in order to handle errors thrown from a vb.net app. In the dll I need several forms (I'm not totally sure if they can have forms - I'm a bit of a newbie when it comes to dll's) for which the user can type in their message about the error and submit it.
I need to be able to pass strings to the form and for the form to be able to access public subs in the class file.
For instance I have a public sub called Emailer, which I want, when the submit button is clicked from the form to be run.
Or, lets say I have a public string:
Public strName as string = nothing
why cant I, from the class file just do this:
frmFormName.strName = "abc"
Not sure if I've explained that very well, but like I said I'm a bit of a newbie with this stuff.
1) You can have froms in a DLL it just does not have a entry point you will need a exe for this this. Which it sounds like you have
2) You will need to add a project reference to a dll from your exe
ok not sure how this will work but try to download this Example project let me know if you have more questions

VB2010: Viewing Object Structure for Learning/Visualization Purposes

I was wondering if there is a way to take an object in Visual Basic 2010 (Express, FWIW) and browse through its structure to visualize how the data inside is laid out.
For example, I have an object called "model" that is populated by a function that is a black box to me. Model is set by a "read" function that loads a DXF file from disk. The read function isn't very well-documented.
What I've discovered is that model.Entities ends up containing a list of different objects, all with different properties. I'd like to be able to simply browse this list of objects and view their associated properties and values at run-time, similar to how you can use Intellisense to view a list simply by typing "blah." and waiting for the pop-up to appear.
A tree view that you can pop open and closed would be excellent. Obviously this has to work during run-time rather than in the editor because the file hasn't been loaded if the program isn't running.
Is this something that's possible in Visual Basic 2010? Is it a built-in feature I can't find?
Thanks!
If a function returns an object, then that object has a class definition somewhere. Right-click the reference in VS and select "View in Object Browser" and you'll see the class layout with all properties and methods. You don't need to do this at run-time, either.
If you want to dig even deeper then you should check out Reflector.
EDIT
After reading your comments more, I usually do one of three things when I'm trying to do this:
Use the Autos and Locals window
Use the Immediate Window
Use "break-point and hover"
Use the Autos and Locals window
Set a breakpoint and check out the Autos and Locals windows. If you don't see them they're under the main menu at Debug, Windows. This allows you to walk a tree-view of your variables. Sometimes there can be a lot of stuff in here which I why I generally use one of the other two methods below.
Use the Immediate Window
The Immediate Window (IW) allows you to type in expressions and print out values. Its not a tree-view like you want but it allows you to hunt and peck at least. If you imagine the following short and simple code and you put a breakpoint on the second line:
Dim Names As New List(Of String)({"Alice", "Bob", "Chuck"})
Console.WriteLine(Names)
In the IW you could type:
?Names
And it would output:
Count = 3
(0): "Alice"
(1): "Bob"
(2): "Chuck"
The question mark symbol means "print". You can type almost any valid expression for print:
?Names(0)
"Alice"
?Names(0).Substring(0,1)
"A"
?Names(0).Contains("ice")
True
And as you're doing all of this you're getting IntelliSense about whatever is going on.
Use "break-point and hover"
I don't think this has a name beyond IntelliSense but once you've hit a breakpoint you can hover over any variable and inspect its current values. You'll get the occasionally warning that inspection will cause some processing but since you're debugging only this should be fine. Sometimes when I'm debugging a collection I'll create a variable specific to one item in the collection just to make this technique easier. I'll get rid of it once I'm done debugging but it really helps this process.
Is there another