Showing posts with label achieve. Show all posts
Showing posts with label achieve. Show all posts

Monday, March 26, 2012

Printing TabContainer

Hi there!

Just wondering if anyone has managed to achieve the following:

I've got a page with a TabContainer in it... and I want to print it. By default the printed page will show the tab container just as it appears on screen.
But that's not what I want!!
I want to the printed page to reflect the contents of the TabContainer e.g.

Tab1

Tab1's contents get rendered

Tab2

Tab2's contents get rendered

etc. etc.

I've had a brief look at how to accomplish this, but am realising this is probably going to take a fair bit of time and effort to do. So I was wondering if anyone had "done the work for me" and I could crib a solution together!!!

Now I suppose you want to know why I want to do this... well basically I'm going to have 100's of pages containing tabs that my users can view. Despite the information being available on screen they love to print anything and everything off for their own records. I really don't want to end up 2 versions of every page... 1 for on screen display... and one made nice and pretty for printing purposes!!

My current thoughts are:

    Write an extender to hook into the beforeprint and afterprint events on the client to "pretty" everything up.

    Write some @dotnet.itags.org.media print and @dotnet.itags.org.media screen to maybe deal with the changes

    Probably my favourite option... write a control adapter for the TabContainer... this could look at a querystring parameter to determine if I am trying to render a printable version or not. If not, render as normal, otherwise change the output so that each TabPanel is visible and lined up vertically one after the other.

Any ideas/thoughts??

Cheers,

James

Hmmm... been thinking about this a fair bit more since I posted... I'm now convinced that the ControlAdapter route is the best.

I'm playing round with a solution that seems to work quite well (and thankfully took a lot less time than I originally anticipated).
Still got a few things to sort out though to make it look "right"!


[Ignore]


[Sorry ignore again]

Saturday, March 24, 2012

Problem forcing an UpdatePanel to post from client-side code (javascript)...

Here's what I'm trying to achieve. I have a rather complex web page that allows data entry. The page utilizes Atlas UpdatePanels for partial reposts. When the user clicks on certain buttons, the data is validated (server-side), and then the user is given the option to save or abandon the changes. To do this, I use RegisterJavaScript to insert a client-side call to a javascript function which calls a vbscript function to display a msgbox (we're only using IE). The vbscript function returns the msgbox value back to the javascript function which then sets an ASP HiddenField. The next step is where I'm having problems. I need the javascript function to force a partial postback so that the server-side code can evaluate the msgbox results (in the hidden field), and respond accordingly. I don't want to repost the entire form because I loose data from other asynchronous client-side page modifications.

So the real question is; how can I force an UpdatePanel to post from client-side code? I've read a number of other threads on this subject and a suggested solution is to call the click event of a hidden LinkButton within the UpdatePanel. So I tried this and it worked! At least it worked for a while. This is the most frustrating part. At some point, and I have no idea what changed to cause this, the code stopped working. Now, when I call the click event, I get an undefined error in the doPostBack function and the form will no long post at all.

If anyone has any suggestions on what is causing this problem, or a better way to force an UpdatePanel to partial post, it would be greatly appreciated!

Here's some of my code;

<atlas:UpdatePanel ID="upConfirmActivitySave" runat="server" Mode="conditional"><ContentTemplate> <asp:HiddenField ID="hfConfirmActivitySave" runat="server" /> <asp:LinkButton ID="lnkDoPostBack" runat="server" style="display:none"></asp:LinkButton></ContentTemplate></atlas:UpdatePanel><script language="javascript" type="text/javascript"><!--function confirmActivitySave() { document.getElementById('hfConfirmActivitySave').value = ConfirmActivitySaveMsgbox(); document.getElementById('lnkDoPostBack').click();} // --></script><script language="vbscript" type="text/vbscript"><!--Function ConfirmActivitySaveMsgbox()'This only works for IEConfirmActivitySaveMsgbox = MsgBox("Do you wish to save?",35)End Function// --></script>

I decided to simplify things and created a new aspx page with a single UpdatePanel and two ASP ImageButtons, one inside the UpdatePanel and the other outside the UpdatePanel. The client-side code for the button outside the UP calls the click method for the button inside the UP. And sure enough, I get a partial post. So this tells me there's something wrong with my main project page. I wonder if I've hit some sort of atlas bug or limitation?


This just gets weirder and weirder. I restored my project to a prior version – one that the partial post code still worked. I compared the differences in the html between the working and non working versions and the only changes were some controls that were renamed (all within UpdatePanels) and a single control (an asp:HyperLink) that moved from outside to inside an UpdatePanel. So, from the working code, I moved the one control (using cut/past) and sure enough the page fails during the client-side partial post; "unknown runtime error". And get this; if I delete the control, the page still fails. By the way, all references to this control (client-side and server-side) have been removed. Essentially, the control is unused. But if I delete it, the page fails. What gives? I can remove other controls, or add and remove controls with no problem. It's almost like there's some reference that's not getting deleted correctly. Any ideas? Anyone?