Home | Articles|Namespace|Interview Questions|Tools|Jobs|Projects|Community
Asp.net Tutorials

»Dotnet Ads
»Message Boards
Message Boards
Dotnet Books

»Member Details
Register
Login
LogOut
Submit Code
Submit Jobs
Submit Projects

»Competition
Community
Winners
Prizes
Write For Us
Members

»Other Resources
Links
Dotnet Resources

Instantiating a asp.net web form dynamically

Instantiating a asp.net web form dynamically from a database using reflections and assembly and saving to session the code shows that


''hope it will be of some use to some body
If rptDetails.UserControl <> String.Empty Then
Response.Redirect("RptForm.aspx")
Else
Dim ObjType As Type = Nothing
Dim rpt As New Report
Try
'Load Assembly
Dim ass As [Assembly] = Nothing
ass = [Assembly].Load("CaI.Reports.BBV")
'Load Type
If Not ass Is Nothing Then
ObjType = ass.GetType("CaI.Object." + rptDetails.FileName.Replace(".rpx", String.Empty))
End If
'Create instance of report type
If Not ObjType Is Nothing Then
'Assign Report Parameters
Dim ReportParameters() As Object
ReportParameters = New Object() {rptDetails.ImagePath}
'Instantiate Report
rpt = CType(Activator.CreateInstance(ObjType, ReportParameters), CommAdminReport)
rpt.ConnectionString = rptDetails.ConnectionString
End If
Catch ex As Exception
lblError.Text = ex.Message
End Try

'Save Report Object to Session
Session("Report") = rpt
End If

Have a Question and dont know the answer post it below and get answers in minutes

Due to spam this feature is disabled
To get answers fast , make sure you enter a detailed subject for example: "DataGrid issues need answer" not "DataGrid"

Subject:

Catjegory Name:

Message:



© 2008 dotnetwatch.com -- Privacy policy