Forum  Commercial Foru...  Commercial Foru...  Catalog Sample - How is the right panel done?
Previous Previous
 
Next Next
New Post 11/11/2010 11:01 AM
  sramirez@dynacal.com
508 posts
1st Level Poster


Catalog Sample - How is the right panel done? 

First off, I like the look of it.  It has "Category" in a nice bar above the "work area"

Second, how is the work area being loaded?  I can't figure out what container it is.

Here is what I am looking to do.

I would to be able to load usercontrols into the "work area".  I have seen samples of doing this but the samples seem to assume that the usercontrol is already loaded onto the form.  If I load them, how do I do it so that the usercontrol doesn't show unless I add it to the container?

I have a main page that has a left nav and a work area on the right side.  The work area could have 1 of 4 usercontrols displayed.  All 4 controls are heavy with data so I don't want them to draw or pull from the database until they are called for by the user.  Then when the user calls for them, the current usercontrol is removed/hidden and the called control is displayed and pulls the data from the database.

I hope that this post makes sense.  I would be grateful for any assistance.

Shawn

 
New Post 11/11/2010 12:06 PM
  palli
14324 posts
1st Level Poster




Re: Catalog Sample - How is the right panel done? 

Hi Shawn,

I believe the "Category" bar is constructed with an obsolete PanelType property of the Panel control. In current versions you would be using the HeaderedPanel control instead.

As for the UserControl loading, I think you will find good links to articles and codesamples in the Wiki UserControl article. There is even one sample that demonstrates loading via reflection, but there are more simple codesamples too.

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 11/11/2010 1:16 PM
  sramirez@dynacal.com
508 posts
1st Level Poster


Re: Catalog Sample - How is the right panel done? 
Modified By sramirez@dynacal.com  on 11/11/2010 5:51:01 PM)

Thanks, I did go through that Wiki article which lead to http://www.visualwebgui.com/Developers/KB/tabid/654/article/working_with_usercontrols_to_simulate_frames/Default.aspx

The sample project had too many errors when i tried to load it in vs2010 VWG 4 so I just gave up.  Even if you can't give me code can you explain the concept of how to do it?

 

Also, does the UserControl need to be a part of the VWG project or can it be part of a VWG library project?  Does it matter if it is in a library project?

One last thing.  The usercontrol would have to interact alot with the form that contains it.  How do you do the event handling in the main form if the user control is being swapped in?

As I have said before, I am new to .net and to VWG.  The application that I am building is for a rewrite of an existing asp classic application that is of a pretty good size.  I don't have the luxury of time in the rewrite so please understand why I am posting questions like a mad man !

Thanks,

Shawn

 

----- Update 5:35pm ------

I have made it work but I am afraid that I am missing something because it is reatively simple.

On my form I have a panel (panel1)

I have created a user control (usercontrol1)

In the main form is a button with a click event.  That event looks like this:

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Panel1.Controls.Clear()
        Me.Panel1.Controls.Add(oControl)
        oControl.MyTest = "help me"
        oControl.LoadMe()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Panel1.Controls.Clear()
        Me.Panel1.Controls.Add(oControl2)
    End Sub

The control is dimmed at the class level with this code

Dim oControl As New UserControl1

Dim oControl2 As New UserControl2

I did this so that I could interact with the control throughout the life of the form.

2 questions remain:

1.  Is this a good approach?  Or am I asking for trouble with this simple approach?  I am planning on less then 5 user controls that would be handled like this (those controls will have a number of controls within them).  Each of these controls will be loading alot of data.  What data will be based off information passed to the usercontrols from the main form so I will have some sort of loaddata function in the usercontrol. 

2.  How do I handle events in the usercontrol so that they will kick off functions in the main form?

Thanks for any insight.

Shawn

 

 

 
New Post 11/11/2010 2:05 PM
  palli
14324 posts
1st Level Poster




Re: Catalog Sample - How is the right panel done? 

Hi Shawn,

Firstly, I updated the article you reference and it now has an additional NET4 / VS2010 download. I updated the code for VS2010, tested and it works fine.

Now to your approach. Usually, I don't do it the way you do it to create an instance of the UserControl up front to keep it living for the lifetime of your form. In your case, where you say each control will load a lot of data, that will just be resource intensive and your user may not even view all the usercontrols, so why bother creating the instance. On top of that, I assume your control will have it's data loading logic within the Load event or something like that, and when you have it loaded once, it will keep it's allocated resources until your form ends it's life.

My prefered method, is to create an instance when I need it and add it to the workspace. Before I do that, I perform "closing procedures" for the control that's already in there, and then destroy that one. This way you only have one active control at a time.

In some cases there is a requirement to have all the controls alive the whole time, and then so be it. Most of the cases, you don't.

There may be needs for two way communications between your enclosing form and your usercontrols. In that case I most often create a base UserControl with some overridable public methods declared, but not necessarily implemented. In each control I create, I override those methods with the specific implementation needed for each type of control. You can for instance have an overridable method called ReindexData(), which you would then override in each of your controls and which would do different things in each control. Your form would then simply cast the usercontrol currently within the workstpace, to your BaseControl's type, and then call that ReindexData() method.

The other way of communication is when your usercontrols needs to contact your enclosing form. This is most often done by declaring events on your usercontrols. When your form creates an instance of your control, it registers an event handler for those events.

Hope this explains. If you need more info, feel free to ask. If you do, please let me know if you are using VB.NET or C# for your coding.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 11/12/2010 2:45 AM
  sramirez@dynacal.com
508 posts
1st Level Poster


Re: Catalog Sample - How is the right panel done? 

Thanks for the help!

I use VB.net

I believe I understand the concepts you speak of and the sample app does work now, Thanks.

When you talk about the overridable public methods... Here are my questions:

1.  how do I reference the methods on base control?  Lets say that the base control is called base1.  So lets say that I want to do a me.base1.SetMyText = "test" (SetMyText is the overrideable method)

2. Now, if I do a SetFrame(new base2) to load a new control, how do I reference the new control so I could use .SetMyText?

Thanks

Shawn

 
Previous Previous
 
Next Next
  Forum  Commercial Foru...  Commercial Foru...  Catalog Sample - How is the right panel done?
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS