Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-23-2009, 9:49 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0
 
Join Date: Jun 2007
Posts: 4
Reputation: 0
elmowatson is on a distinguished programming path ahead
Default How to get a reference to Ajax

I am using a PropertyGrid control. There are two things I need to be able to do.
1. I need to be able to access Ajax controltoolkit components and populate the propertygrid with the properties from the Ajax control toolkit.
2. I need to be able to do the same with WebUI components.

The basic part, populating the propertygrid with a control, I understand how to do - -

What I don't know is what to import or how to access what dll (for the Ajax Control Toolkit and the Web UI controls), in my Winforms project to be able to do this.

Can anyone give me a little help here, please?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-24-2009, 6:57 AM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

You can't use web controls in winforms projects.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-24-2009, 11:35 AM
VB.NET Forum Newbie
.NET Framework: .NET 2.0
 
Join Date: Jun 2007
Posts: 4
Reputation: 0
elmowatson is on a distinguished programming path ahead
Default

I don't really want to use them in the project itself - I just want to access the dlls and get the properties - -
Technically VS.Net does it, so there must be some way, I would think
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-24-2009, 3:54 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

I see, you have to use the 'Add Reference' dialog to add the assembly that has the class you want, documentation for the standard web controls say they are in assembly System.Web. For example for the TextBox class you can see this:
Quote:
Originally Posted by help
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
When you have added the reference you can use the class, either import the namespace or qualify the type like this:
Code:
Me.PropertyGrid1.SelectedObject = New System.Web.UI.WebControls.TextBox
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-25-2009, 5:12 PM
VB.NET Forum Newbie
.NET Framework: .NET 2.0
 
Join Date: Jun 2007
Posts: 4
Reputation: 0
elmowatson is on a distinguished programming path ahead
Default

Theoretically, anyone using this application will have the DotNet platform on his/her computer.
So, once I've done this - if I compile and package the application - but the AjaxControlToolkit is not installed with DotNet - - Will the end user need to have this dll installed somewhere on his/her computer, or should my reference (and therefore, dll in the Bin and in the installed local app) in the project be enough to be able for the user to use the application?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-25-2009, 7:18 PM
JohnH's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Dec 2005
Location: Norway
Age: 37
Posts: 10,173
Reputation: 1273
JohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond reputeJohnH has a reputation beyond repute
Default

If you reference a assembly your app becomes dependent of it, it must be present in order for your app to run. In deployment scenario it must then be included in setup for local libraries ('copy local' setting), or as a prerequisite (something that must be installed first) for external libraries such as the .Net Framework and the AjaxControlToolkit where these libraries are installed to GAC.

It is also possible to use libraries without referencing them at design time, by loading them dynamically at runtime using Reflection. You can then not write any strongly typed code for these libraries, only discover them with the Reflection type system. The most basic example is this, same as the Textbox example only now System.Web assembly is not referenced:
Code:
Dim asm As Reflection.Assembly = Reflection.Assembly.Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
Dim o As Object = asm.CreateInstance("System.Web.UI.WebControls.TextBox")
Me.PropertyGrid1.SelectedObject = o
Reflection and the example above has little interest if you have to write the control names manually, so I include a more advanced example that show how control types can be discovered and listed, and later used to create dynamic instances to be assigned the PropertyGrid. This method loads all public types from System.Web that is derived from WebControl and belongs to System.Web.UI.WebControls namespace, and that has a parameterless contructor, much similar to the controls in the web toolbox probably.
Code:
Private Sub LoadWebControls()
    Dim asm As Reflection.Assembly = Reflection.Assembly.Load("System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
    Dim webControlType As Type = asm.GetType("System.Web.UI.WebControls.WebControl")
    Dim controlTypes As New List(Of Type)
    For Each t As Type In asm.GetExportedTypes
        If webControlType.IsAssignableFrom(t) AndAlso t.Namespace = "System.Web.UI.WebControls" Then
            Dim flags As Reflection.BindingFlags = Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public
            Dim ctor As Reflection.ConstructorInfo = t.GetConstructor(flags, Nothing, Type.EmptyTypes, Nothing)
            If ctor IsNot Nothing Then
                controlTypes.Add(t)
            End If
        End If
    Next
    Me.ListBox1.DataSource = controlTypes
    Me.ListBox1.DisplayMember = "Name"
End Sub
When user selects as type in listbox the existing control instance in PropertyGrid is disposed and the new instance is created:
Code:
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
    Dim o As Object = Me.PropertyGrid1.SelectedObject
    If o IsNot Nothing Then
        CType(o, IDisposable).Dispose()
    End If
    Dim t As Type = CType(Me.ListBox1.SelectedValue, Type)
    o = Activator.CreateInstance(t)
    Me.PropertyGrid1.SelectedObject = o
End Sub
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 12:58 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.