Visual Studio 2012 - The Install - NO Problems!

by George24. September 2012 16:31

Well I finally decided to take the plunge and upgrade to VS 2012. Since I am a member with WebSpark they give me a free download for VS 2012 Professional. Thanks I will make good use of it for sure.

Fear and loathing always come to mind when upgrading this particular beast as there is just so much that can go wrong. But never the less I downloaded the ISO image. The download only took about an hour or so if my recollection is correct. I then burned it to a DVD and ran the install.

It worked perfectly!

I mean no problems at all. I was able to open any site or project form VS 2010 into VS 2012 work with them then open them back up in VS 2010 without a hitch. Well I least that I could see. You can even run both VS 2012 and VS 2010 side by side. YeHA!

So I guess that presses the question was it worth it. Well I have only had a weekend to play with the new VS 2012 but I have to say the new Java Script debugging features is well worth it by it self.

The IDE is mostly the same except for the new look and Icons. I think that is the most frustrating bit right now is having to get used to the new Icons. It's like what the hell is that and where did the book mark thingy go? Things that will pass with time.

As things pop up I will comment on them

Tags: ,

Visual Studio | Visual Studio 2012

Who Knew! Mix and Match ASP.NET Web forms with VB.NET and C#.NET Code.

by George24. September 2012 16:23

Recently, and by complete accident I pleasantly discovered that you can mix web pages created with either C# or VB page behinds within in the same website! Why did I not know this before? Oh well learn something every day. And this is a good one to know about as it will save oodles of time.

Tags: , ,

Request.UrlReferrer - Things I learned

by George9. August 2012 16:41

While working on a couple of eCommerce sites I learned that the Request.UrlReferrer does not always work! 

I wanted a button that would return the user back to the previous page after he has just added an item to his shopping cart.

I was doing something like this:

//create a string to store the URL and save the previous page to the string in the Page_Load event
    string str;
    protected void Page_Load(object sender, EventArgs e)
    {       
            str  = Request.UrlReferrer.ToString();
     }

    //Then redirect the page back to the previous page
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(str);
    }

Just one problem with this, It Didn't Work!

I was getting "not set to an instance of an object" errors constantly in the error log files. Turns out that the Request.UrlReferrer does not like working within Master Pages.

So what to do? Javascript to the rescue! It was the most simple and elegant solution to the problem. All you have to do is to add one line of code to your page load event like this.

 protected void Page_Load(object sender, EventArgs e)
    {
        ImageButton1.Attributes.Add("onClick", "javascript:history.back(); return false;");
     }

And the problem is solved.

Hope this saves someone some time!

Tags: , , ,

ASP.NET | C#

Telus segue

by George9. August 2012 16:29

Well in a week from discovering the problem Telus sent out a very helpful tech guy who discovered that there was really no problem on my end because their modem had crapped out! He put in a new one and I got the Windows 7 machines up and running fast but the XP machines were another story. The default encryption settings for Windows 7 and XP are different but their new modem does not know this so I spend 2 hours with mostly incompetent beginning help desk guys but they finally got their modem to work with both. Now I have high speeds once again,

Tags:

Telus disappoints as ISP this week

by George30. July 2012 08:38

I have been with Telus for more than 15 years.

But yesterday they really let me down.

On Sunday mornings I always do a weekly disaster data back up of the databases on my web server. It usually takes just under an hour to download all the db files. Well yesterday it took over 11 hours! Plus an hour on the phone with the Telus "Geniuses" to tell me that they could not figure out why my connections is suddenly so slow. They said they would have to send someone out and that the earliest was this coming Friday between noon and Sunday to see if its my fault because I must have changed something at my end. They also said they would charge me for the call if they did find changes! Well there have been no changes. None. It has been the same for... let me see 15 years at least.

I tried to tell them that this has happened before and that the problem was that one of your "Geniuses" flipped the wrong switch down and the hub. But no they have to make me suffer for 5 days with this "internet". This is not what I am paying for. I want a rebate.

And to think that before I got up Sunday morning I was thinking what a great day this would be! Was I wrong. wrecked my whole day and week.

too be continued...

Tags: , ,

Filling a ASP.NET Listbox via SQL Datareader

by George22. July 2012 10:41

 

Here is a simple and frequent task that programmers do that will be useful to beginners.

HTML MarkUp

<asp:ListBox
    ID="ListBox1"
    runat="server"
    AutoPostBack="True"
    Width="175px"
    Height="400px"
    onselectedindexchanged="ListBox1_SelectedIndexChanged">
</asp:ListBox>

I like to format my control attributes each on a single line. Make sure to set your AutoPostBack to True so the onselectedindexchanged Event will fire when the user selects a user from the listbox

Code Behind

 public void Fill_ListBox()
    {
        // always clear your list box before filling or you get duplicate items or a very long list
        ListBox1.Items.Clear();

       // Filling the datareader with First and Last name as well as UserID
        SqlDataReader dr = content.RetrieveAnyContent();

        // Read the contents of reader
        while (dr.Read())
        {
            //Create a new ListItem to be added to the asp.net Listbox.
            // This way you can not only show the text you want the user to view but assign a item value to use when the list box is clicked
            // like the user ID
            ListItem item = new ListItem();

            // Use a string builder to join the first and last names together
            StringBuilder sb = new StringBuilder();
            sb.Append(dr["FirstName"].ToString().Trim());
            sb.Append(" ");
           sb.Append(dr["LastName"].ToString().Trim());

            //Assign values to the item text and item value
            item.Text = sb.ToString();
            item.Value = dr["userID"].ToString().Trim();
            //then add the item(s) to the list box
            ListBox1.Items.Add(item);
        }

       // don't forget to close your Datareader
        if (!dr.IsClosed)
        {
            dr.Close();
        }

    }



    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string userID = ListBox1.SelectedValue.ToString();
        Response.Redirect("http://localhost/site/Users.aspx?userID=" + userID);
    }

This is the way it will look in you are using URL Parameters but if you are using page routing it will look a lot different. But now thinking of how I am doing things lately I have given up the listbox in favor of HTML/CSS User lists for the hopes of improving the SEO my sites. I will show how that works in my next post. Its not that much extra work but it really make your site a lot more Google Friendly.

 

Until Next time.

[a]

Tags: , ,

.net | ASP.NET | C# | SQL Server | Visual Studio

How to become programmer in 12 easy years.

by George21. July 2012 10:43

First, read and study the following:

Well that's sort of how it works.

Over the past 12 years of my new self imposed career I have learned a thing or two million. But the most important thing I have learned about programming I did not learn from any of the above.

The most important thing about programming and life I guess is that you need to know what you want. Of course this is not as easy as it sounds. So where did I learn this if not from programming? Ok, here is the story.

I was a brand new school band director fresh out of University teaching a decent jazz band, and concert band. It was a big program so I was team teaching with another experienced teacher. Just like programming there are different styles / approaches for what a jazz band should sound like. Kind of like difference between C# and VB, maybe. Anyway I was taught in a style more like Stan Kenton's band while the other teacher was schooled more like the style of Count Basie. While both valid and great bands if you try to mix their styles you end up with a mess. You have to decide what you want. You can't do both.

Well festival time came and Dominic Speara was the adjudicator ( lead trumpet for Henry Mancini) saw the problem right away and the first words out of his mouth where, "you need to know what you want".

 So in a way that's how I came to find my new career as programmer / web developer.

12 years after my first jazz band festival I found my self as the owner of a private music school and music retail store. The music school was getting big and the administration of it was getting out of hand, so I started looking for software that would fit the bill. I searched for about 6 years but there was nothing like what I wanted. Since I knew what I wanted started working with MS Access and progressed to SQL server and beyond. The end result was Music Teacher's Office which we still use to this very day that saves us about 30 hours a month of administration time.

Now the first iterations of the application were awful. but as I gained more skills and knowledge if finally came into place. But it all started off with me knowing what I wanted.

Now the second most important thing as a programmer you need to know if you want to make a living as a programmer is that you need to learn what your client wants.

All the books and knowledge in the world, however necessary, will not bring you success if you don't know what you or your client wants or needs.

Tags:

General

Welcome - first post

by George20. July 2012 12:13

Well it must be time for my first post.

To get things started this blog will be mostly about programming and web development.

I will post a lot of code that has helped me along my way over the years in hopes that it will help others find solutions faster.

I am a .Net kind of guy programming in C# and VB and ASP.net. as well as Windows forms by the way of Visual Studio 2010.

Until next time

gj

Tags: , , , ,

.net | C# | General | VB | Visual Studio | Windows

Page List