in

vbCity Blogs

New (temp) place for vbCity Blogs

Serge B. Blog

  • How to ResolveUrl() without Page context in ASP.NET

    There are times you need to resolver relative URL like "~/my/link.aspx" into ablsolute and you don't want to use the Page context or can't easily access it.

    Rick Strahl posted a great blog entry on ResolveUrl() without Page where he implements his own static ResolveUrl() method.

    I found that System.Web namespace has method VirtualPathUtility.ToAbsolute that does exactly the trick.

    You don't even need declare VirtualPathUtility class in VB for it is static.

    Dim _resolvedUrl As String = VirtualPathUtility.ToAbsolute("~/my/link.aspx")
    

    And while you are on MSDN web site, feel free to explore other useful method of the System.Web.VirtualPathUtility class.

  • Increase VMWare virtual disk size

    While installing VS2008 SP1 on a 8GB VMWare machine today I encountered the need to increase the virtual hard drive size - didn't have enough space for the SP1 setup to run.

    Luckily, VMWare has vmware-vdiskmanager utility which I used and very much followed the Increase your Virtual machine's disk capacity post instructions.I had to clone my VM to remove all snapshots - vdiskmanager requirement.

    The only problem I ran at was that the diskpart utility wouldn't expand the capacity of the disk and fail.

    On second reading I noticed the following comment

    If the disk is the system volume you will need to mount the disk in a second VM and expand it from there. If its not a system volume do it within the virtual machine it belongs to.

    I only have drive C on all of my virtual machines as, I'm sure, most of you out there.

    So, don't forget - you need to add the virtual disk file as secondary drive to another VM (VM B) and expand the disk on VM B, at this point you can remove the disk from VM B and start your VM A with new disk size.

    Another post Increase the size of your VMWare disk drive by Carl Tyler points to VB UI wrapper for the vmware-vdiskmanager utility, and tips on expanding virtual machine that has snapshots.

    Edit: One more useful article with screenshots - Expanding a drive within a VMWare image

     

    Posted Dec 31 2008, 12:17 AM by Serge B. with no comments
    Filed under:
  • How to format source code in vbCity forums and blogs

    To highlight code in your forum, blog and wiki posts wrap code into the folowing tags (example below is for VB.NET Code)

    [code language="VB.NET"][/code]

    Languages supported (in alphabetical order):

    • C
    • C++
    • C#
    • COBOL
    • Eiffel
    • Fortan
    • Haskell
    • HTML
    • Java
    • Javascript
    • Mercury
    • MSIL
    • Pascal
    • Perl
    • PHP
    • Python
    • Ruby
    • SQL
    • Visual Basic
    • VBScript
    • VB.NET
    • XML

    Visual Basic example:

    Public Sub CreateMyMultilineTextBox()
        ' Create an instance of a TextBox control.
        Dim textBox1 As New TextBox()
    
        ' Set the Multiline property to true.
        textBox1.Multiline = True
        ' Add vertical scroll bars to the TextBox control.
        textBox1.ScrollBars = ScrollBars.Vertical
        ' Allow the RETURN key in the TextBox control.
        textBox1.AcceptsReturn = True
        ' Allow the TAB key to be entered in the TextBox control.
        textBox1.AcceptsTab = True
        ' Set WordWrap to true to allow text to wrap to the next line.
        textBox1.WordWrap = True
        ' Set the default text of the control.
        textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line"
    End Sub
    

    C# example:

    public void CreateMyMultilineTextBox()
     {
        // Create an instance of a TextBox control.
        TextBox textBox1 = new TextBox();
    
        // Set the Multiline property to true.
        textBox1.Multiline = true;
        // Add vertical scroll bars to the TextBox control.
        textBox1.ScrollBars = ScrollBars.Vertical;
        // Allow the RETURN key in the TextBox control.
        textBox1.AcceptsReturn = true;
        // Allow the TAB key to be entered in the TextBox control.
        textBox1.AcceptsTab = true;
        // Set WordWrap to true to allow text to wrap to the next line.
        textBox1.WordWrap = true;
        // Set the default text of the control.
        textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line";
     }
    

     

    Posted Sep 29 2008, 08:11 PM by Serge B. with no comments
    Filed under: ,
  • How to wrap text inside <pre> tags in all browsers

    While looking for line-wrapping solution for syntax highlighted code blocks on the new vbCity community web site and had (once again) to search for the right <pre> tag CSS attributes that'd wrap code in all browsers. So, I ran at this great post that summarizes it all nicely and in one post:

    Wrapping Text Inside Pre Tags - http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/

    Be sure to scroll down to the end of the article as Tyler keeps updating it with new attributes.

    Her is the latest style I use on this site that I found in Tyler's post:

    pre {
     overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
     white-space: pre-wrap; /* css-3 */
     white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
     white-space: -pre-wrap; /* Opera 4-6 */
     white-space: -o-pre-wrap; /* Opera 7 */
     word-wrap: break-word; /* Internet Explorer 5.5+ */
    }
    

     

Copyright 1998-2009 vbCity.com LLC
Powered by Community Server (Non-Commercial Edition), by Telligent Systems