Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am using multiview webcontrol within which I have about 10 views, each view has a reference to user control (ascx page). with button Next or Prev I am switching active views. In my multiview I have set active view index to be the first view.
My only problem is I want to load only active view but its running all the asp page life cycle of sub-sequent view. i.e it is hitting all the break points of page load event for all the views. in page load i have lots of db calls and I want to only trigger the page load event for the view that is active. I have went through this article
https://msmvps.com/blogs/luisabreu/archive/2008/02/20/multiview-control-should-you-use-it.aspx[^]

but its not helping, I am using vb code so I changed this to below code as per above article

Protected Overrides Sub Render(writer As HtmlTextWriter)
Dim contentPlaceHolder As ContentPlaceHolder = DirectCast(Master.FindControl("cphBody"), ContentPlaceHolder)
Dim activeView As String = myMultiview.GetActiveView.ID
If activeView IsNot Nothing Then
contentPlaceHolder.FindControl(activeView).RenderControl(writer)
End If
End Sub

I would really appreciate if anyone can point me to right direction. thanks
Posted

anybody? so should I assume I shouldnt use multiview control?
 
Share this answer
 
Comments
Lalit PB 31-Mar-12 7:32am    
I think each time when post back happens, each view of a multiview control is also goes through its life cycle.since it is a child control of multiview control, we cannot avoid it.
oh ok. so what will be the best way so I could get good performance in my case?
 
Share this answer
 
Comments
Mohamed Mitwalli 2-Apr-12 13:19pm    
make it Comment or Question don't add new solution
uglyeyes 2-Apr-12 22:32pm    
ok if its goes through the page cycle, how can i check which view is active in ascx so i can avoid running databind if this ascx is not active?
uglyeyes 25-Apr-12 21:39pm    
if not, how do I at least check which view in multiview is active at the beginning so I could set the active view property in page load of aspx so I check that value in page load property of all ascx and if the viewname matches current view where ascx resides call the load() function in page load event of ascx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900