Advertise here


Tag cloud


 

You are currently browsing the archives for the Top Tips category.

Archive for the ‘Top Tips’ Category

Convert int array to string array

Posted on Saturday, September 10th, 2011 in Top Tips

Quick and useful way to convert an int array to a string.

int[] ints = new[] { 2, 5, 90, 49}
string[] strings = Ids.Select(m => m.ToString()).ToArray();

What is happening? We are moving through each item in the array and converting it into a string. They will all be in a string format and it is then assigned to the string array. The same is done below except it is from a string to an int array. This can be applied to most other array types.

String array to int array


string[] strings = new[] { "1", "2", "3" };
int[] ints = strings.Select(x => int.Parse(x)).ToArray();

Make navigation elements hover over flash.

Posted on Monday, August 1st, 2011 in Top Tips

I was working on a drop down menu which unfortunately was dropping behind a flash advert, so most of the navigation items were not visible.

There are essentially two things you need to do to combat this small issue. Firstly the flash object (embed tag) needs to have wmode attribute and set to transparent. A param tag also needs to be added, setting the wmode, as seen in the example below.

<embed wmode="transparent" />
<param name="wmode" value="transparent" />

The menu class then needs the z-index set to a very high value in this case: 9 999 999 to layer above the flash item. The item also needs to have an absolute position for the z-index to take affect. The reason for using z-index is because this controls the layers level in the web page, essentially the depth. Flash objects and web forms naturally have a high z-index and this is why most elements appear below them. The simple script can be used over web forms as well, you don’t need to do anything special to the forms.

Z-index the higher the value the near to the top it will be.

.menuItems{
      position:absolute;
      z-index: 9999999;
}

Use both Apache and IIS servers

Posted on Tuesday, July 12th, 2011 in Top Tips

In some cases you might find yourself having to use Apache and IIS locally to test our your sites. Unfortunately you can’t have both running at the same time as they both use port 80.

When you install the development tools for .Net applications, IIS is installed as well by default. After this or when ever you start up your machine IIS will automatically turn on, which will prevent you from running Apache. Read more


Developer tool Notepad ++

Posted on Friday, June 24th, 2011 in Top Tips

NotePad Plus Plus Logo free Text editor One of the most useful developer tools that I have come across while developing is NotePad ++. It is simple and lightweight so it loads up ultra quick. This is really useful when you just want to edit or create a text based document. The great thing about it is its completely free. So there is a good reason why you should download and play around with it.

Notepad ++ has some excellent features like the find and replace which can use regular expressions as well. It allows you to search with in a folder, all open documents, generate a list of where it found a match and can replace in all open files. There are plenty utilities on the find and replace making its so very useful for fast development. Read more


Console C# getting database connection string from app.config file

Posted on Monday, November 1st, 2010 in Top Tips

When writing a console application using C# / .NET and you want to connect to a database, the connection string is typically stored in the app.config file. Below is an example of a web.config which is the same an app.config file used in C#.Net. It is essentially an XML file that stores required data to make your application work. It keeps these bits of data in one place, making it easy to manage when things change. There will be no need to hunt down connection strings or other configuration data with in your application code.

To extend further on this top tip I have written a tutorial on how to use CSharp with MySQL.

 <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
       <ConnectionString>
         <add key="MySQL.DB" value="server=localhost;database=mysqldbname;user=username;password=12345678;" />
       </ConnectionString>

       <system.web>
        <compilation defaultLanguage="c#" debug="true" />
      </system.web>

    </configuration>

To access the connection string the first step would be to make sure that a reference is added to System.Configuration. Then make sure you include it in the class using System.Configuration and the code below is used to access the connection string.To access the connection string the first step would be to make sure that a reference is added to System.Configuration. Then make sure you include it in the class using System.Configuration and the code below is used to access the connection string.

using System.Configuration;

string MysqlConnectionString = ConfigurationManager.ConnectionStrings["dbconnectionstring"].ConnectionString;

This method can also be used to access the app.config file for any web applications.


Remove link border when clicked

Posted on Thursday, October 28th, 2010 in Top Tips
CSS Top Tip

How to get rid of the dotted border around a link when it has been clicked.

a {
    outline: 0;
}

Stop auto complete on web forms

Posted on Thursday, October 21st, 2010 in Top Tips

On web forms the browser stores previously typed in data and if you start typing in the same data a dropdown list appears below with these options. Sometimes this can be annoying and gets in the way when you use the form regularly with unique data each time. To turn this function off on selected form elements use the following code:

<input type="text" value="test text" autocomplete="off" />

Use the attribute in the input element autocomplete with the value off to stop the drop down list appearing.



Web Design Essex | Richard Kotze – Web Technology, Design and Development powered by WordPress | Entries (RSS)