Tuesday, December 29, 2009

.net join for arrays

If you're used to the old way of converting an array into a comma delimited list, here's the new way(?). It's been there, but you may not have used it.

String.Join(",", array);

How do I add Head tags in .net using c#

There are of course many tags you can use. Here are a couple to get you started... Also, don't forget to set the Title as well. (this.Header.Title = "this is the title";)

  1. keywords
  2. description
  3. robots
  4. date


HtmlMeta metatag = new HtmlMeta();
metatag.Name = "Description";
metatag.Content = "Here's a great description.";
this.Header.Conrols.Add(metatag);

OR, I like it this way...


HtmlMeta metatag = new HtmlMeta(){

   Name = "Description",
   Content = "Here's a great description.",
};

this.Header.Conrols.Add(metatag);

Friday, December 18, 2009

How do I urlencode in an aspx file

I ran across this while using a repeater. Of course, it can occur in a datagrid as well. The data that's coming from the datasource has & signs and spaces. When the & comes across, and it's put into a query string as a parameter, it's not translated right when sent to the next page. So, I want to encode it so the request.querystring will work. Here's the solution:


Tuesday, December 15, 2009

type of conditional expression cannot be determined because there is no implicit conversion between null and bool

Have you seen this?
Type of conditional expression cannot be determined because there is no implicit conversion between null and bool

I received this because I was doing an inline if statement (ternary I think) setting the value to a boolean. The boolean value I was setting was nullable. And, because I did want to set the value to null in some cases, this error was showing. To fix it, I just did the following (bool?)null. Then it all worked out

Friday, December 4, 2009

Favorite Visual Studio shortcut keys

Stop Debugging: SHIFT + F5
View code in full screen mode: ALT + SHIFT + ENTER
Go to Definition: F12
Close Window: CTRL + F4

Thursday, December 3, 2009

Telerik RadWindow Clicking on the link doesn't do anything

Not sure if you encountered this before. Essentially, when using the Telerik RadControls RadWindow, specifically in this case the RadWindowManager and trying to use a modal window, there is an assumption I didn't realize. When you update your OpenerElementID you are supposed to set it to the id of the control whether it's a link, linkbutton, whatever. Well, initially, I set this to the ID of the control. In reality, it must be the actual ID of the control. To get this, load your page, then get the name via the HTML source.

Wednesday, December 2, 2009

How to get the date in a sql statement (TSQL)

To get the date in a select statement, stored procedure, etc. You can use the getdate() function.
For example, you can do

Select getdate()

Getting the word out about this site

Ok, here's where we get a little bit selfish. But, wanted to get more traffic, so we added ourselves to yousaytoo.com. If you want to know more about it go here:

Make Money Blogging