Forum  General Visual ...  How do I...?  How to make a preview form based on parts of another form...?
Previous Previous
 
Next Next
New Post 7/28/2011 6:01 AM
Unresolved
  unil
6 posts
No Ranking


How to make a preview form based on parts of another form...? 

I hope anyone of you have done this before, because its hard to find any solution on the web...
My need is to generate a kind of preview form which is based on parts of another form.

Example: Form1 contains a header/banner, several buttons and small images, some textual info and a scrollable panel with lots of controls filled with database data (called DataPanel1, which contains the "real juice" of this form). By clicking a button in Form1, a new form called Form2 shall appear containing the content of DataPanel1 only. In short, Form2 is a stripped down version of Form1, and will act as a kind of preview window, which the user may print or export to PDF.

Form1 is pretty complex with tons of code so its really no option to duplicate it in order to design and maintain a Form2.
The appearance of the DataPanel1 is dynamic both in length and content depending on user choices and status flags in the data, so a preview must be based on the current appeareance of this panel. I kind of print screen snapshot is no option either since the panel may be longer than the screen height

The questions are:

  • Is it possible to transfer controls from one form to another, in a simple way like this: Form2.Previewpanel = Form1.DataPanel1...?
  • If not, could Form2 be generated dynamically on the fly as a HTML-copy of the Datapanel1, but still with all its controls in their right positions...?
  • As an option, could the DataPanel1 be transfered/exported directly to PDF (or Word or Excel)...?

Thank you very much for any ideas on this.
:)Unil

 
New Post 7/28/2011 2:43 PM
  palli
14324 posts
1st Level Poster




Re: How to make a preview form based on parts of another form...? 

Hi Unil,

I don't have any complete solutions for you, but I can give you some ideas, and then tell you about what is coming in the newest versions of Visual WebGui, release 6.4.0 Release d.

You may well try to "transfer" your previewpanel from one form to another. You could do that by creating a dialog form, remove the panel from the first form and then add it to your dialog form. The problems with that is that every time you will do that, it will rebind it's datasources and of course redraw it's contents, so this might not be such a good idea... of course depending on the contents.

Other options I can think of, include the following:

Option 1 - dynamically copy server-side:

This means that on the click of a Button (for instance), you write server-side code to go through all the controls on your panel you want to print and make new instances of each control, adding it to your new preview form (or whatever you would use). This has the same drawbacks as before, as this would mean rebinding and redrawing etc.

Option 2 - retrieve the Html and open in a new form.

This is actually very simple, and by issuing a this.InvokeScript(string.Format("w=window.open(); w.document.write($(VWG_{0}).html()); ",this.PreviewPanel.ID));  This would open a new browser window with the Html contents. The problem here is that the Html contents would appear there without any of the supporting framework's code, so you are very likely to get errors when the Html reacts to some events, that just are not there. The Html might be processed further to remove all the event triggers before opening the window, so possibly this might help you to get started in what you called "copy Html".

Option 3 - Use the new Control.DrawToBitmap() - available 6.4.0 Release d

This is a new public method that will produce a bitmap of any control. You can see a code sample attached to this tracker entry here. When doing simple tests on this method just now, I think it's not fully ready for all controls, but it will of course be, hopefully in Release d. With this method you would be able to create a Gateway that would return a jpg image of your panel that you could then open in a new browser window. This may not be what you are looking for though, and it may be impractical when the panel's height reaches a value where this would mean multipage.

Option 4 - Build a specific preview version

This is somewhat like the first option, but here you might want to use another format. Some users have made preview versions of their forms for printing by running through all the data and writing out Xml for instance, possibly by further processing, even by using xslt to make some transformations that would suit your output requirements.

This is about all I can think of at the moment.

Hope this gives you some ideas and some help,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 8/3/2011 7:28 AM
  unil
6 posts
No Ranking


Re: How to make a preview form based on parts of another form...? 

Thanks Palli, this was really helpful!

I think Option 3 - Use the new Control.DrawToBitmap() could be very useful and I look forward to check it out when VWG 6.4.0 Release d is available.

I also tried Option 2 - retrieve the Html and open in a new form, like this:
Me.InvokeScript(string.Format("w=window.open(); w.document.write($(VWG_{0}).html()); ", Me.DataPanel1.ID))
(where DataPanel1 contains the part of the parent form that is to be previewed).

This was really a nice solution, it displays controls of the DataPanel1 in a new form, ready to be printed.

However, the width of all textboxes in the new form is clipped (seems to be shortened to a default size). 
And it does not display all the controls of the source panel (= DataPanel1, which is actually a scrollable panel in the parent form).
The new form only shows controls up to the screen height of the new form. And the vertical scrollbar of the new form is "stiff", it doesn't even change when the new form is resized to a smaller height.

This is strange, but could this be due to the browser I'm using (IE8 running on XP)....? I know there have been some issues concerning scrollbars on IE8...

 

 
New Post 8/6/2011 4:52 AM
  palli
14324 posts
1st Level Poster




Re: How to make a preview form based on parts of another form...? 

Hi Unil,

I doesn't surprize me that Option 2 doesn't fully work "out of the box", as I did mention in my earlier reply that all of the Html's "supporting code" is not copied with it, and that also applies to the CSS. To use this, you would need to get hold of, or create, the required CSS.

At the moment, I would recommend option 4, of creating a specific preview form, as I think that would be the most straightforward option that wouldn't require too much experimentation and uncertainity.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
Previous Previous
 
Next Next
  Forum  General Visual ...  How do I...?  How to make a preview form based on parts of another form...?
.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