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

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

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