Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Controls
Message
De
30/08/2005 07:29:46
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
User Controls
Divers
Thread ID:
01045077
Message ID:
01045077
Vues:
56
All,

I have a user control that I am trying to reference in a webform. All I'm trying to do is set a property on the user control in the Page_PreRender event. However, in the Pre_Render event the value for the control is nothing or not an object. The code is below, please help.

WebForm Code
    Public Class _default
    Inherits System.Web.UI.Page
    Protected WithEvents cmdInsertSession As System.Data.SqlClient.SqlCommand
    Protected WithEvents lblMessages As System.Web.UI.WebControls.Label
    Protected WithEvents grdProducts As FeaturedProducts


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
         ...
    End Sub


    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
        Me.grdProducts.ProductType = Me.grdProducts.GridType.Features
        Me.grdProducts.GetProducts()
    End Sub
End Class
User Control Code
Public MustInherit Class FeaturedProducts
    Inherits System.Web.UI.UserControl
    Protected WithEvents dsFeatures As WebCartMaintenance.dsWebShopper
    Protected WithEvents daFeatured As System.Data.SqlClient.SqlDataAdapter
    Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
    Protected WithEvents dgFeatures As System.Web.UI.WebControls.DataGrid
    Protected WithEvents cmdAddToCart As System.Web.UI.WebControls.Button
    Protected WithEvents btnAddToCartBottom As System.Web.UI.WebControls.Button
    Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand
    Protected WithEvents SqlCommand2 As System.Data.SqlClient.SqlCommand
    Protected WithEvents daCart As System.Data.SqlClient.SqlDataAdapter



    Public Enum GridType
        Features = 1
        BrandName = 2
        Cart = 3
        Order = 4
    End Enum

    Private _producttype As String
    Public Property ProductType()
        Get
            Return _producttype
        End Get
        Set(ByVal Value)
            _producttype = Value
        End Set
    End Property

     ....
    Public Sub GetProducts()
       ...
    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Me.GetProducts()
    End Sub

End Class
Thanks

Jim
Répondre
Fil
Voir

Click here to load this message in the networking platform