These are the new glasses I got. After almost seven years with my current pair, I decided do buy two new pair. The one one the left is an invisible type metal frame and the one on the right is a black plastic frame. I like the invisible one better for everyday use, but the plastic frame is nice to use when I need to focus on a task and get things done. Sounds strange but it seems to work for me.
Author: patrick
-
Microsoft XML Notepad 2007
XML Notepad 2007 is now my favorite XML editor. This thing is so simple but so cool. Makes editing and viewing the hierarchy of an XML file so easy.
Even has find and replace, full namespace support, and even XML Diff support.
The killer feature, if anyone has used Visual Studio… Intellisense based on expected elements and attributes. No more guessing the required schema, it enforces it.
I’ve thrown some large XML files at it and it loads in seconds. This is cool!
Best of all, its free. So if you work with XML, go download this now!
-
Windows Live Writer Testing
After installing BlogEngine.Net and really loving it. I decided to give Microsoft’s Windows Live Writer a try.
This post has been written completely in WLW.
I was able to add this picture and even add the title and sepia tone to it.
Table
Values
One Two Three Four It can do all kinds of things like insert a table (see above) and even code snippets like:
if (this == that) { response.redirect("/somepage.aspx"); }
and insert maps
of the Metrodome in Minneapolis, MN
-
When Design Overrides Product
what’s wrong with this picture? What exactly is the point of this product if you have to look over your shoulder? I am sure someone said, why are we seeing the back of the girls head? So the designer got another photo of her looking back.
-
Switched from WordPress to BlogEngine
Well, after a bit of fun, I have moved my website over to IIS 7 from Apache 2. Also, moved from WordPress to BlogEngine.
Since I have moved all my personal and work development to ASP.NET, I figured it was time to move my website over.
I think I have the major links fixed and redirecting properly, but I am sure I’ve missed some.
If you have any issues, let me know. I think the comments system is working?
-
Windows 7 Beta Notes
Well, first attempt was on my Thinkpad w500 and that failed hard. But it appears it was probably because of the switchable graphics card.
I installed the beta on my mac mini, which is the media center computer, and it works well. Faster, but boot camp support for drivers is limited at best. Hopefully Apple will come out with drivers soon. One issue on the mini, after watching a movie in Media Center, media center crashes.
Since I didn’t get the w500 working with Windows 7, I did switch over to using that as my main computer, so that left the Thinkpad t61p to play around with. Installed Windows 7 on the t61p was a snap. Of course I had a bit of a challenge forgetting my dvd rom drive at the office in the docking station. Thanks to my obsolete HD-DVD Xbox 360 drive, I was able to install Windows 7.
Install went well, most of the lenovo drivers installed fine, although I’d like to see more supported drivers, but that will happen at launch.
I highly recommend anyone wanting to play around with the next desktop OS from Microsoft try Windows 7. It is a much better experience than Vista, faster, easier to use and once released, the drivers and support will be much better ( I hope ).
Anyway, this post came from the new Windows Live Writer which is a great tool to post entries to many types of blogs.
-
Install WordPress 2.6.3 on IIS 7 and Windows 2008
I tried installing WordPress 2.6.3 on my dev Windows 2008 server running IIS 7 and .Net 3.5sp1 and could not get it working.
I went back to 2.6.0 of wordpress which installed just fine and then did the upgrade to 2.6.3 which worked. No idea why it didn’t install, but something clearly changed between 2.6.0 and 2.6.3 to break IIS 7 installs.
Oh well, now to figure out how to get comments and other functions in WordPress to work under IIS7, got permalinks working, but think it broke the comments feature. I love the new URL Rewrite Pack for IIS7 as well as the Media Streaming Bandwidth throttle option for IIS 7.
Can’t believe I am saying this, but the last couple of months working with IIS 7 has converted me from Apache. Still wish IIS 7 could do wildcard binding without dedicating an IP and retain the web.config file across publishes from Visual Studio 2008, but oh well. I also wish that the ASP.NET Visual Studio Web Server could understand the URL Rewrite statements in the web.config file and route the links appropriately instead of having to publish to my local IIS 7 install in Vista. Also wish that IIS 7 could be installed on XP.
Oh well, at least I got WordPress running and MySQL on it, so that means I can start testing the various WordPress sites I have moving from Apache to IIS 7. Next up is cleaning up my WordPress export to BlogML for Blogengine.net import. Oh well, lots to do, little time to do it.
-
How to Show Your Meta Description and Keywords on an ASP Master Page
So today’s challenge was to display the Title, Meta description and meta tags on a site I am currently working on for troubleshooting and SEO reasons.
The solution I came up with was to place the following code in the code behind of the masterpage.
protected void Page_Load(object sender, EventArgs e) { HtmlHead headTag = (HtmlHead)Page.Header; Response.Write("Title of Page: " + headTag.Title + ""); foreach (var control in Page.Header.Controls) { var test = control.GetType(); if (test.Name == "HtmlMeta") { if ((control as HtmlMeta).Name == "Description") { Response.Write("MetaDescription : " + (control as HtmlMeta).Content + ""); } if ((control as HtmlMeta).Name == "Keywords") { Response.Write("MetaKeywords : " + (control as HtmlMeta).Content + ""); } } } }
The HeadTag.Title gives us the Title of the current page.
The foreach loop jumps through each control in the header section of the current page.
Since there can be different types of controls in the header section, we need to check for the type of HtmlMeta.
Then we need to check to see if it is the Description or Keywords and return the content values.I am sure there are other ways, but this is a really simple way to display the 3 main SEO elements, Page Title, Page MetaTag Description and Page MetaTag Keywords for all the ASP.NET pages that use this master page (or you can place it on each page code behind) without having to view the source code.
Just remember to remove this code before you launch your site 🙂
-
WPF Dynamically Added Controls and Getting Values
Today’s challenge was fun.
I had added a bunch of textboxes and labels to a Grid with 2 StackPanel in my code behind.
StackPanel sp1 = new StackPanel(); StackPanel sp2 = new StackPanel(); Grid g = new Grid(); ColumnDefinition colDef1 = new ColumnDefinition {Width = new GridLength(50)}; ColumnDefinition colDef2 = new ColumnDefinition(); g.ColumnDefinitions.Add(colDef1); g.ColumnDefinitions.Add(colDef2); gb.Content = g; Grid.SetColumn(sp1,0); g.Children.Add(sp1); Grid.SetColumn(sp2, 1); g.Children.Add(sp2); for (int i = 1, i < = 4, i++) { Label lbl = new Label {Content = "Name", Margin = new Thickness(0)}; Grid.SetColumn(lbl, 0); sp1.Children.Add(lbl); TextBox fieldname = new TextBox {Text = "", Name = "fieldname" + i, Margin = new Thickness(0,5,0,0)}; Grid.SetColumn(fieldname, 1); sp2.Children.Add(fieldname); }
So I then wanted to get the results of what someone types into these TextBoxs.
But wait, I can’t just access them like this:
string t = fieldname1.Text;
Why? Only Microsoft knows, but apparently, dynamically added controls can’t be accessed this way since they don’t exist in the XAML code.
So, how does one access them then? Well, that’s where this cool LogicalTreeHelper function to find the control by name we use the FindLogicalNode option of the LogicalTreeHelper function
So to loop through the number of fields you added you can do the following:
List test = new List; for (int i = 1; i < = 4; i++) { test.Add((LogicalTreeHelper.FindLogicalNode(Fields1, "fieldname" + i) as TextBox).Text); }
So there you have it, a simple way to access dynamically added controls using LogicalTreeHelper and FindLogicalNode just remember to name your controls you add.
-
Writing Out LINQ to XML Documents to CSV Text Files
This may sound stupid, but I wanted to store some text parsing I was doing for some VDP projects in LINQ to XML XDocuments.
So, I created the following:
XDocument recs = new XDocument();
XElement records1 = new XElement("Records");
XElement record1 = new XElement("Record");
record1.Add(new XElement("id", "1"),
new XElement("Name","Test"),
new XElement("Address","123 Anywhere")
);
records1.Add(record1);
recs.Add(records1);
which should create an xml document looking like this:
<Records>
<Record>
<id>1</id>
<Name>Test</Name>
<Address>123 Anywhere</Address>
</Record>
</Records>So, I want to write this out to a CSV file. But I want to assume that my XML Nodes might change (but at least stay consistent throughout the XML Document) by datasource and I want to systematically write out the names of the nodes and then loop through and write out the values.
So the hard part:
var list2 = from el2 in recs.Elements("Record")
select el2;
//Build Header Line
StringBuilder csvlist = new StringBuilder();
var headers = (list2.First().Nodes().ToList());
int cc = 1;
foreach (var node in headers)
{
csvlist.Append((node as XElement).Name);
if (cc != headers.Count)
{
csvlist.Append(",");
}
cc++;
}
csvlist.AppendLine();
foreach (var t in list2)
{
for (int i = 0; i < t.Nodes().Count(); i++)
{
csvlist.Append((t.Nodes().ToList()[i] as XElement).Value);
if (i != (t.Nodes().Count() - 1))
{
csvlist.Append(",");
}
}
csvlist.AppendLine();
}
So at the end of all this, csvlist contains the headers and data as comma separated.There are lots we could add or fix in this, but it allows us great flexibility in outputting xml data as delimited text.
DISCLAIMER: I am not a professional coder, I do this as a passion. The above code has no warranty or ability to actually do what I say it does. Use at your own risk, fix, add or change if you are willing.