Friday, March 27, 2009

Using jQuery to display the complete contents of a textbox when printing

When printing a web page that contains text inputs (a.k.a. a TextBox in ASP.NET) overflow content can be missing if the control isn't large enough. I've put together a small jQuery script that adds a span next to each text input that is usually hidden. The content of the span is then set to match the content of the input, including if the content is changed.

Note: In my case putting an overflow:visible; in the CSS wouldn't be sufficient.

jQuery

        $(document).ready(function(){
            
            $('input[type="text"]').each(function () {
                    $(this).after('' + $(this).val() + '');
                });
            
            $('input[type="text"]').change(function () {
                var textbox = $(this);
                var id = textbox.attr('id');
                $('#' + id + ' + span').each(function (){
                    $(this).text(textbox.val());
                    });
                }); 
        });

CSS

  
 .printOnly
 {
  display: none;
 }

 @media print { 
  input[type='text']
  {
   display:none;
  }
 
  .printOnly
  {
   display: inline;
  }
 }

Creating a temporary ASP.NET Profile provider in Session

See the ASP.NET forums: Profile provider that uses session?

Wednesday, March 25, 2009

Modal popup test using jQuery and jqModal

The following JavaScript link will display a modal dialog using jQuery and jqModal.

Show Modal

Close
Test Modal This is a testing modal dialog

Saturday, March 21, 2009

Friday, March 20, 2009

Using one stored procedure from another.

I went with the a temporary table, INSERT and EXEC as I didn't want to modify the existing stored procedures.

See How to Share Data Between Stored Procedures

Test internal methods

The InternalsVisibleToAttribute can be used to expose internals from one library to another. See TDD: Test internal methods the correct way.

Monday, March 16, 2009

Getting the Date Builder module in Yahoo Pipes to accept a string

The documentation for the Date Builder module suggests it will accept text input and create a date time from it. But if you try to wire a Text Input straight to it you can't because the data types don't match. See the suggestion Date Builder Module Accept Text.