Here's some of my old VB code:
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