Sunday, April 20, 2008
9:34:09 PM
Failed Projects
While looking through some of extra files littering my Website folder, I noticed most of the abandoned projects shared a common theme, they were all database driven. I had taken a course in databases previously and had actually done very well in the class. For some reason though, I could never get things to work right or the way I wanted them to. Connection string issues and other problems seemed to plague these projects as I eventually became frustrated and abandoned them. I figured I knew what I was doing and didn't need to research anything when I should have dusted off my old database book.
Sunday, April 20, 2008
8:09:51 PM
iPod Interface
My computer was dead for over a week during the semester, and I found myself doing most of my web browsing and e-mail on my iPod. There are a lot of websites that have optimized their sites for iPhone and iPod touch use. These sites were a lot easier to navigate than their traditional counterparts.
I edited the CSS file for this blog to make navigation easier and simplified for using these smaller screens. I stripped out the menu and formatted the blog to fit the standard screen size and set up a redirect from the blog to the special iPhone version of it. Overall, it's a lot cleaner and easier to navigate and read. It can be found here.
Sunday, April 20, 2008
8:09:51 PM
Format Code
I was getting annoyed posting code into this blog and having the formatting go haywire. I made a quick little form to format all of this text for me automatically in the Experiments section.
Here's the C# code after I ran it through the program:
public partial class Experiments_Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder(TextBox1.Text) ;
sb.Replace(" "," ");
StringReader sr = new StringReader(sb.ToString());
StringWriter sw = new StringWriter();
while(sr.Peek()>-1)
{
string temp = sr.ReadLine();
sw.Write(temp+"
") ;
}
TextBox2.Text = sw.GetStringBuilder().ToString();
}
}
Sunday, April 20, 2008
8:09:51 PM
Experiments Section
I set up an experiments section today using MasterPages. This wasn't too difficult at first after getting the hang of how they work. I then reworked some of the other pages to take advantage of the section and added a menu for the whole thing. The experiments section is located here.
Sunday, April 20, 2008
8:09:51 PM
Calendar Function and Experiment
I started messing around with the ASP Calendar control. It was incredibly easy to use and was set up only using a couple lines of code. After setting it up on the experiment page, I messed around with it a little manipulating the data and fooling around with labels. I then took on the more difficult task of implementing it into my blog. After spending some time understanding how the code worked on the blog, I added the function GetBlog(bool reverse, int year, int month, int day) into the Blog.cs file. The function I added was:
public string GetBlog(bool reverse, int year, int month, int day)
{
int n = items.Length;
if (n == 0)
return "";
StringBuilder builder = new StringBuilder();
if (reverse)
{
for (int i = (n - 1); i >= 0; i--)
{
DateTime datetime = items[i].BlogItemCreationTime;
if ((datetime.Year == year) && (datetime.Month == month) && (datetime.Day == day))
builder.Append(items[i].ToString());
}
}
else
{
for (int i = 0; i < n; i++)
{
DateTime datetime = items[i].BlogItemCreationTime;
if ((datetime.Year == year) && (datetime.Month == month) && (datetime.Day == day))
builder.Append(items[i].ToString());
}
}
return builder.ToString();
}
This added the support to select blog entries by the day. After implementing this and making some more changes to the other blog files, I was able to select the blog entries by date. After setting this up to select by date, I made the calendar control able to select the blog posts by date. There were two quirks with it, one of which I was able to fix. When turning the calendar function on without selecting a date would make things blow up. The default functionality for this now selects the current date if you're trying to turn it on without a date selected. The other quirk makes it so you have to select the date twice to get the page to load properly. I'm not exactly sure why it's doing this; I'm sure it has something to do with the postbacks and how things are loaded, but I was unable to pinpoint a fix for this. As of right now, you must double click the date to sort the blog posts.
Sunday, April 20, 2008
8:09:51 PM
Calculator Experiment
I set up a simple calculator experiment to mess around with text boxes and manipulating their input. This was pretty easy and straight forward for the most part, but I wanted to make sure the server didn't crash when given invalid input.
protected void Add_Click(object sender, EventArgs e){
try
{
AnswerLabel.Text = Convert.ToString(Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text));
}
catch (FormatException)
{
AnswerLabel.Text = "Invalid input";
}
}
This is the code for one of the four standard operations. By surrounding the calculation in a try/catch block and capturing any invalid inputs, this made it simple to catch the error and make the label say "Invalid input."
Wednesday, April 02, 2008
8:39:56 PM
Ctrl+A User Control Implemented
I implemented my Ctrl+A user control that I previously created into my blog today.
The process was relatively easy. The blog software puts all of the content into a div
with the class name "page_content." To implement the user control, all you have to do
is copy the file \UserControls\SelectTextByID.ascx into your project and drag and drop
the file into your blog page. It should look something like this:
<div class="page_content" id="Div1">
Target="select" is where you call the ID of the item you want to select. You can change "select" to
the id of the div you wish to select. You must also change one more line:
<div class="page_content"> is in the default.aspx page for the blog. The control will work when you
change this line to:
<div class="page_content" id="select">
Now the user control sees the content, and will only select text within that div. Now when you hit Ctrl+A you will no
long select the blog entries box in the upper right corner as well.
Wednesday, April 02, 2008
8:23:31 PM
Test Blog Entry
This is only a test.