Wednesday, October 29, 2014

Get httpPostedFileBase FileName only code or extract last portion of file director path

var httpPostedFileBase = Request.Files.Get("DocumentFileName");
               var myFileName = string.Empty;
               if (httpPostedFileBase != null)
               {
                   int position = httpPostedFileBase.FileName.LastIndexOf('\\');
                   myFileName = httpPostedFileBase.FileName.Substring(position + 1);
               }

Wednesday, October 15, 2014

Reading Keys from Web.config file.

Try using the WebConfigurationManager class instead. For example:
C# string userName = WebConfigurationManager.AppSettings["PFUserName"];
OR
VB.NET Dim userName as String = WebConfigurationManager.AppSettings("PFUserName")

Read file using FileStream - Reference - http://www.csharp-examples.net/filestream-read-file/

Read file using FileStream

First create FileStream to open a file for reading. Then call FileStream.Read in a loop until the whole file is read. Finally close the stream.
[C#]
using System.IO;

public static byte[] ReadFile(string filePath)
{
  byte[] buffer;
  FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
  try
  {
    int length = (int)fileStream.Length;  // get file length
    buffer = new byte[length];            // create buffer
    int count;                            // actual number of bytes read
    int sum = 0;                          // total number of bytes read

    // read until Read method returns 0 (end of the stream has been reached)
    while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)
      sum += count;  // sum is a buffer offset for next reading
  }
  finally
  {
    fileStream.Close();
  }
  return buffer;
}

Wednesday, October 01, 2014

jQuery $.ajax call add functions you will need to call after the html is rendered.

I am adding the following blog post because I spent a good amount of time working on figuring the following out.

Using the jQuery function $.ajax I learned that you need to be sure to add all the functions you want to perform actions on after the $.ajax loads the new content to the page.

CORRECT CODE
<script type="text/javascript">
    $("#addItem").click(function () {
        $.ajax({
            url: this.href,
            cache: false,
            success: function (html) {
                $("#editorRows").append(html);
                $("a.deleteRow").on("click", function () {
                    $(this).parents("div.editorRow:first").remove();
                    return false;
                });
            }
        });
        return false;
    });

</script>

This makes 100% sense because if you code it as follows it will never work because the .append(html) is not on the page currently when the jQuery loads.

BAD CODE
<script type="text/javascript">
    $("#addItem").click(function () {
        $.ajax({
            url: this.href,
            cache: false,
            success: function (html) {
                $("#editorRows").append(html);
            }
        });
        return false;
    });

//Following will not be called --- because it is not on the page currently
    $("a.deleteRow").on("click", function () {
        $(this).parents("div.editorRow:first").remove();
        return false;
    });
</script>


Hope this helps.  Have fun coding.

Wednesday, September 17, 2014

pragmatic - Word of the day

prag·mat·ic
pragˈmatik/
adjective
  1. dealing with things sensibly and realistically in a way that is based on practical rather than theoretical considerations.

SSL Chrome

SSL certificate technology is always improving to stay ahead of hackers. We regularly update to the most current and effective standards. We recently switched from using SHA-1 certificates to the more secure SHA-2 algorithm for new certificates.
Google Chrome is a very popular internet browser. Starting in November, they'll begin displaying errors on the padlock icon for any website using SHA-1 SSL certificates. Learn more here.


The following SSL certificate(s) are still using the SHA-1 algorithm. Re-key them to update to SHA-2 and avoid problems in November.

Wednesday, May 28, 2014

Determine .NET Version - Shared by Walt Daniels

Run this from a Command prompt (not a powershell prompt) … it takes a minute, be patient.


wmic /namespace:\\root\cimv2 path win32_product where "name like 'microsoft%.NET%'" get name, version

Friday, May 09, 2014

jQuery Lightbulb

If you want to learn jQuery, which is a hot tech skill these days head over to www.codecademy.com

The following statement had the light bulb go off:

VERY IMPORTANT ---

You know a lot about jQuery events already, but it never hurts to review the basics.
The setup almost always looks like this:
$(document).ready(function() {
    $('thingToTouch').event(function() {
        $('thingToAffect').effect();
    });
});
where "thing to touch" is the HTML element you'll click on, hover over, or otherwise interact with, and "thing to affect" is the HTML element that fades away, changes size, or undergoes some other transformation.
Sometimes these elements are one and the same—you might hover over a <div> to change its opacity. Other times, you might interact with a separate element; for example, you might click on a button to resize a <div>.
Sometimes if you want an effect to occur right away, without an event like .click() or.hover(), you'll skip the second line in the above:
$(document).ready(function() {
    $('thingToAffect').effect();
});

Wednesday, March 26, 2014

Reset Visual Studio Windows if Windows Start opening in different panes

Windows:  ALT + W, R 
Menu:   Window | Reset Window Layout 
Command:  Window.ResetWindowLayout 
Versions:  2005, 2008, 2010, 2012, 2013 

Monday, March 10, 2014

LINQ Queries OR SQL checking Nothing or Null Values

You need to check if it's Nothing first and use the AndAlso keyword to stop it from evaluating the latter statement. Also, when checking if the and object is null, you should use the Is or IsNotoperator rather than =. This should work

Dim otherRecords As List(Of Objects) = listOf.Where(Function(x) _
                                                        (x.ID_NUM = newID) AndAlso _
                                                        (x.Codes IsNot Nothing) AndAlso _
                                                        (x.Codes.Contains(ddlPrimaryCode.SelectedItem.Text.Trim()))).ToList()

Tuesday, March 04, 2014

Stored Proc Place holder to be filled later example

SELECT

Field1,
Field2,
Field3,
' ' AS FieldName,
FROM tbl_name
WHERE field = @param


Later fill this with the data you need.

Wednesday, February 05, 2014

TFS MSBuild Workflow Toolbox

Do you still have the Team Foundation Build Activities tab?  If not, you probably deleted it.  To get it back, you can right-click on the toolbox and select "Reset Toolbox". This will get it back to the default, which should contain the lost tab.
You could also add them by right-clicking on the toolbox, then "Choose Items", then "Browse" and select C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.Build.Workflow.dll.

Monday, January 06, 2014

LAWS OF PROJECT MANAGEMENT

1. No major project is ever installed on time, within budget, or
with the same staff that started it. Yours will not be the
first.

2. Projects progress quickly until they become 90% complete,
then they remain at 90% complete forever.

3. One advantage offuzzy project objectives is that they let
you avoid the embarrassment of estimating the
corresponding costs.

4. When things are going well, something will go wrong.
• When things just cannot get any worse, they will.
• When things appear to be going better, you have
overlooked something.

5. If project content is allowed to change freely, the rate of
change will exceed the rate of progress.

6. No system is ever completely debugged. Attempts to debug
a system inevitably introduce new bugs that are even harder
to find.

7. A carelessly planned project will take three times longer to
complete than expected; a carefully planned project will
take only twice as long.

8. Project teams detest progress reporting because it vividly
manifests their lack of progress.