Hi. I have this code below and wondering what file I need to import to get the pageContentsCell.Controls.Add(control) line to work.
Private Sub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles MyBase.Load,Me.Load' Save DepartmentID from the query string to a variableDim departmentIdAs String = Request.QueryString("departmentID")' Save the search string from the query string to a variableDim searchStringAs String = Request.QueryString("Search")' We need to find out if the ViewCart parameter has been suppliedDim viewCartAs String = Request.QueryString("ViewCart")' Load page contentsIf Not viewCartIs Nothing Then' we display the shopping cartDim controlAs Control control = Page.LoadControl("UserControls/ShoppingCart.ascx") pageContentsCell.Controls.Add(control)ElseIf Not searchStringIs Nothing Then' you're searching the catalogDim controlAs Controlcontrol = Page.LoadControl("UserControls/SearchResults.ascx") pageContentsCell.Controls.Add(control)ElseIf Not departmentIdIs Nothing Then' you're visiting a department or categoryDim controlAs Controlcontrol = Page.LoadControl("UserControls/Catalog.ascx") pageContentsCell.Controls.Add(control)Else' you're on the main pageDim controlAs Controlcontrol = Page.LoadControl("UserControls/FirstPage.ascx") pageContentsCell.Controls.Add(control)End If End Sub Private Sub viewCartButton_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles viewCartButton.Click' Get the query string as a NameValueCollection objectIf Request.QueryString("ViewCart")Is Nothing Then Response.Redirect("default.aspx?ViewCart=1&" & _ Request.QueryString.ToString())End If End SubWhat's the error message you got for the linepageContentsCell.Controls.Add(control)? You may take a look atCreating Custom Web Controls with ASP.NET 2.0
0 comments:
Post a Comment