Cyprich.com

Occasionally Relevant Insights from a Software Builder

By

Gigabytes of Free Books from Microsoft!!!

Once again, Microsoft is giving away gigabytes of free books. Eric Ligman (Microsoft Director of Sales Excellence Blog) announced on July 11 that even more books than last year are freely available. If Microsoft is trying to gain loyalty by giving away free stuff, its working. 🙂

You have the option of downloading individual books or all of them in one shot with a PowerShell script. I recommend running this in Visual Studio Code with the Code Runner plugin. If you only cut and paste the code in VS Code and not save it, you’ll have to use the Select Language Mode (lower right corner) to choose PowerShell before you can run it. I downloaded books selectively and it resulted in 3.88 GB of files.

Anyways, I want to thank Microsoft for supporting developers and the IT community with the resources to do our jobs well.

By

How to Fix Multiline TextBox Word Wrap in Edge / IE 11

Internet Explorer 11 and Edge work in a different way with fixed width text boxes (see examples below) than previous versions earlier than 11. IE 11 and Edge inherits the white-space property from its parent. So, if text overflows in these browsers, it won’t wrap in the box.

HTML:

     <textarea rows="4" cols="50">Lots of text ...</textarea>

ASP.NET:

     <asp:TextBox ID="TextBox_Address" runat="server" Rows="5" TextMode="MultiLine"></asp:TextBox>

This can be fixed by applying the following CSS to the text box:

     white-space: pre-wrap

Now overflowing text will wrap in the box in all IE and Edge versions.

By

C#: Bonjour Monde!

This is the Canadian version of the “Hello World! program that every programmer learned in the first 5 minutes of their schooling. Compile this as a console project to test if your compiler is working.

ConsoleApplication1
{
  class Program
  {
    static void Main (string [] args)
 
   {
      Console.WriteLine (“Bonjour Monde!”);
 
     Console.ReadKey ();
 
   }
  }
}

By

How to Copy Contents of HTML Textbox to Another

I recently made changes to a web form that populated a PDF through an XFDF file. In the new code, instead of outputting to an XFDF, the page outputs to an HTML file. Everything worked great, except the HTML page lacked one feature the PDF did. If you have 2 fields with the same name on a PDF, when you update one field, the other field automatically gets the same content. This naming trick won’t work in HTML.

The sample code below will copy the contents of a textbox to another textbox without using JavaScript. The updates occur during each key press. I’ve include examples in standard HTML and ASP.NET. The red text is the code you use to copy one textbox to another.

HTML:

<form name="aForm" action="" method="" />
  <input type="text" name="TextBox1" onkeyup="document.aForm.TextBox2.value = this.value" />
  <input type="text" name="TextBox2" />
 </form>

ASP.NET:

<asp:TextBox ID="TextBox1" runat="server" onkeyup="document.aForm.TextBox2.value = this.value"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

By

How to Replace QLingo with JavaScript in a uStore Dynamic Document

Programmed elements in a dynamic document for XMPie uStore can be built using JavaScript instead of QLingo. Follow the steps below:

  1. Don’t use JavaScript in InDesign with the ADOR objects. All of the programming will take place in uPlan.

  2. In uPlan, create the variables and campaign dials for the ADOR objects that will be used as variables in functions.

  3. Create the function in JavaScript.

    function ShowPersonalCorporation (star1, star2, star3)
    {
     if (star1 || star2 || star3)
       return "*Personal Real Estate Corporation";
    }

  4. Call the function in the ADOR object.

    ShowPersonalCorporation (@{_Star1}, @{_Star2}, @{_Star3})


Testing for Null Values


In QLingo, you would test for a null value by using the IsNullOrEmpty function, which would return a value based on its result (true: display real estate info; false: display nothing):


if (!IsNullOrEmpty (@{_Star1}))

{

 â€ś*Personal Real Estate Corporation”

}

else

{

 â€śâ€ť

}


The JavaScript equivalent is:


function ShowPersonalCorporation (star)

{

 if (star)

   return “*Personal Real Estate Corporation”;

}