something like;
UserControl uc= Load(filename.dll);
Lou
You'll need to look at the Assembly class. In particular, loading an
assembly and then creating instances of classes found in the assembly.
You may want to also look at AppDomains, so that you can load the assembly
in its own AppDomain. Otherwise, once the assembly is loaded, it cannot
be unloaded (you can't unload Assemblys, just AppDomains).
Pete
-Lou
"Peter Duniho" <NpOeS...@nnowslpianmk.com> wrote in message
news:op.uo3jp...@macbook-pro.local...
> Any Source code to look at. I am new to C#.
I don't have any lying around myself. MSDN usually has some code
examples, and of course you can probably turn up useful examples using
Google.
Dim ctlNextSearch As Control = LoadControl("Search.ascx")
CType(ctlNextSearch, SearchControl).SearchString = "whatever"
CType(ctlNextSearch, SearchControl).SearchNumberForNext = someNumber
CType(ctlNextSearch, SearchControl).LastSearchNumber = anotherNumber
Controls.Add(ctlNextSearch)
The first and last lines are the basic Load and Add functionality, but if
you want to set some properties of the user control, use the lines that
begin with CType (. I think the C# would look like:
Control ctlNextSearch = LoadControl("Search.ascx");
(SearchControl)ctlNextSearch.SearchString = "whatever";
etc
Controls.Add(ctlNextSearch);
The vb code for the user control is below.
Hope this helps,
Justin Dutoit
<%@ Control ClassName="SearchControl" Language="VB" %>
<%@ Import Namespace="Quickshop" %>
<%@ OutputCache Duration="10" VaryByParam="*" %>
<script runat="server" language="vb">
Public SearchString As String
Public SearchNumberForNext As Integer
Sub Page_Load(Sender As Object, E As EventArgs)
Dim ConnectionString = "provider=sqloledb.1;data
source=(local);Connect Timeout=30;database=H_justindutoit;User
ID=justindutoit;Password=paulpaul;Packet Size=4096;"
Dim Products As ProductsDB = New ProductsDB(ConnectionString)
MyDataGrid.DataSource = Products.SimpleSearch(SearchString)
MyDataGrid.DataBind
MyDataGridTitle.Text = "Results for '" & SearchString & "'"
ShowUplevelOrDownLevelColumns
If MyDataGrid.Items.Count = 0 Then _
NoResults.Visible = True Bookmark.Attributes("Name") = "Search" & SearchNumberForNext
LinkToNextBookmark.Attributes("href") = "#Search" & (SearchNumberForNext +
1)
End Sub
"Lou" <lou.g...@comcast.net> wrote in message
news:uSjbndti...@TK2MSFTNGP03.phx.gbl...
Seems like it should be simple to load a user control from file.
In VB6 (Which is my background and why I'm haveing troubles)
it's easy:
Dim o As Object
Set o = CreateObject(ClassName)
That's it.
Confused!!!!!!
Any help is appreciated. I have spent two days and many hours googling
and no one has an answer.
-Lou
"Justin Dutoit" <an...@anon.com> wrote in message
news:upryg8zi...@TK2MSFTNGP02.phx.gbl...