Friday, August 13, 2010

Cannot connect to YouTube using iPhone

Do you guys also get the ”Cannot connect to YouTube” error on your iPhone when using the provided YouTube application?

If yes follow the steps below to get it fixed.

1. Open Cydia from your spring board.

2. Press on the Manage tab in the bottom.

3. Press on Sources, then on Edit and press again on Add to add a new source.

4. Type the URL http://apt.iphonemodding.com and press on Add Source button.

5. Now find the iPhoneModding item and press on the triangle ‘>’.

6. Scroll down and find the “Push Fix” item and press on it.

7. Press Install to get Push Fix installed on your iPhone.

8. After pressing confirm on the confirmation screen the application will get installed on your iPhone.

 

9. After a complete restart you will be able to use YouTube application within your iPhone.

Monday, August 09, 2010

Comparing SharePoint 2010 vs 2007

It is some time since the SharePoint 2010 is released and now is a good time for you to migrate to the new improved version of it. When searching the net I found some good sites which compares the 2 versions.

Read through the following sites if you are interested.

http://www.rharbridge.com/?page_id=103

http://www.khamis.net/blog/Lists/Posts/Post.aspx?ID=4

Sunday, August 08, 2010

Installing and Uninstalling Internet Explorer 8

Since Internet Explorer (IE) 8 is a built-in feature of Windows Server 2008 R2 there is no way to install or uninstall it using the user interfaces. Instead you need to run the following commands in a command prompt window which has administrative privileges.

If you are only having IE in your machine as an internet browser be sure to install another internet browser before uninstalling IE, otherwise you will not be able to browse internet.

  1. Click the start button and type Cmd in the search box.
  2. Right click on the Cmd icon and click on Run as Administrator.
  3. Choose the appropriate command from below for your need and copy it.

To Install -

dism /online /Enable-Feature /FeatureName:Internet-Explorer-Optional-amd64

To Uninstall -

dism /online /Disable-Feature /FeatureName:Internet-Explorer-Optional-amd64

or

FORFILES /P %WINDIR%\servicing\Packages /M Microsoft-Windows-InternetExplorer-8*.mum /c "cmd /c echo Uninstalling package @fname && start /w pkgmgr /up:@fname /norestart"

  1. Paste the command into the command prompt windows you just opened by right clicking and clicking on Paste.
  2. Press enter to run the command, when the command is successful you need to restart your machine to complete the action.

Tuesday, August 03, 2010

Rounding a value Down

If you did work with .Net Math classes you may have noted that you can quite easily round value upwards. But what about rounding values down?

For example if you tried to round the value 1.23501 into 2 decimal places using the Round method provided by the Math class as below, the result you will get is 1.24. Meaning .Net had rounded the value up.





  1. double dbl = Math.Round(1.23501, 2);




If the value is rounded down it should be 1.23, but in .Net I couldn’t find an easy way to get this done. So I did create a small code to get it done. It is very simple only a method with one statement as shown below.





  1. double RoundDown(double Number, int Digits)
  2. {
  3.     try
  4.     {
  5.         return Math.Truncate(Number) +
  6.             (Math.Floor(Math.Round((Number % 1), Digits) * Math.Pow(10, (Math.Round((Number % 1), Digits).ToString().Length - 3)))) *
  7.             (1 / Math.Pow(10, Math.Round((Number % 1), Digits).ToString().Length - 3));
  8.     }
  9.     catch (Exception)
  10.     {
  11.         MessageBox.Show("Error ! Please check values.");
  12.         return 0.0;
  13.     }
  14. }




Ohh, I think this is complicated right? Please find a bit of self explanatory code below.





  1. double RoundDownExplained(double Number, int Digits)
  2. {
  3.     try
  4.     {
  5.         // Get the whole number from the double value.
  6.         // For example we'll take Number = 788.34567 and Digits = 3.
  7.         // WholeNumberPart = 788.
  8.         double WholeNumberPart = Math.Truncate(Number);
  9.         // Getting the decimal part from the doouble value.
  10.         // DecimalNumberPart = 0.3457.
  11.         double DecimalNumberPart = Math.Round((Number % 1), Digits);
  12.         // Finding the number of decimal places so we can multiply by 10 to make it suitable for Floor().
  13.         // MultiplicationValue = 3.
  14.         int MultiplicationValue = Math.Round((Number % 1), Digits).ToString().Length - 3;
  15.         // Create the double value to round down.
  16.         // RoundedDownValue = 345.
  17.         double RoundedDownValue = Math.Floor(DecimalNumberPart * Math.Pow(10, MultiplicationValue));
  18.         // Finding the value to devide the result to make it decimal again.      
  19.         // DivisionValue = 0.001.            
  20.         double DivisionValue = 1 / Math.Pow(10, MultiplicationValue);
  21.         // Creating the decimal part with rounded down value.
  22.         // RoundedDownValue_Float = 0.345.
  23.         double RoundedDownValue_Float = RoundedDownValue * DivisionValue;
  24.         // Creating the full rounded down value.
  25.         // return = 788.345.
  26.         return WholeNumberPart + RoundedDownValue_Float;
  27.     }
  28.     catch (Exception)
  29.     {
  30.         MessageBox.Show("Error ! Please check values.");
  31.         return 0.0;
  32.     }
  33. }




The complete code of the application I created is below with a screenshot of the application running. Hope this helps to you.





  1. using System;
  2. using System.Text;
  3. using System.Windows.Forms;
  4. namespace WindowsFormsApplication1
  5. {
  6.     public partial class Form1 : Form
  7.     {
  8.         public Form1()
  9.         {
  10.             InitializeComponent();
  11.         }
  12.         double RoundDown(double Number, int Digits)
  13.         {
  14.             try
  15.             {
  16.                 return Math.Truncate(Number) +
  17.                     (Math.Floor(Math.Round((Number % 1), Digits) * Math.Pow(10, (Math.Round((Number % 1), Digits).ToString().Length - 3)))) *
  18.                     (1 / Math.Pow(10, Math.Round((Number % 1), Digits).ToString().Length - 3));
  19.             }
  20.             catch (Exception)
  21.             {
  22.                 MessageBox.Show("Error ! Please check values.");
  23.                 return 0.0;
  24.             }
  25.         }
  26.         double RoundDownExplained(double Number, int Digits)
  27.         {
  28.             try
  29.             {
  30.                 // Get the whole number from the double value.
  31.                 // For example we'll take Number = 788.34567 and Digits = 3.
  32.                 // WholeNumberPart = 788.
  33.                 double WholeNumberPart = Math.Truncate(Number);
  34.                 // Getting the decimal part from the doouble value.
  35.                 // DecimalNumberPart = 0.3457.
  36.                 double DecimalNumberPart = Math.Round((Number % 1), Digits);
  37.                 // Finding the number of decimal places so we can multiply by 10 to make it suitable for Floor().
  38.                 // MultiplicationValue = 3.
  39.                 int MultiplicationValue = Math.Round((Number % 1), Digits).ToString().Length - 3;
  40.                 // Create the double value to round down.
  41.                 // RoundedDownValue = 345.
  42.                 double RoundedDownValue = Math.Floor(DecimalNumberPart * Math.Pow(10, MultiplicationValue));
  43.                 // Finding the value to devide the result to make it decimal again.      
  44.                 // DivisionValue = 0.001.            
  45.                 double DivisionValue = 1 / Math.Pow(10, MultiplicationValue);
  46.                 // Creating the decimal part with rounded down value.
  47.                 // RoundedDownValue_Float = 0.345.
  48.                 double RoundedDownValue_Float = RoundedDownValue * DivisionValue;
  49.                 // Creating the full rounded down value.
  50.                 // return = 788.345.
  51.                 return WholeNumberPart + RoundedDownValue_Float;
  52.             }
  53.             catch (Exception)
  54.             {
  55.                 MessageBox.Show("Error ! Please check values.");
  56.                 return 0.0;
  57.             }
  58.         }
  59.         private void button1_Click(object sender, EventArgs e)
  60.         {
  61.             try
  62.             {
  63.                 label1.Text = RoundDown(double.Parse(textBox1.Text), int.Parse(textBox2.Text) + 1).ToString();
  64.             }
  65.             catch (Exception)
  66.             {
  67.                 MessageBox.Show("Error ! Please check values.");
  68.             }
  69.         }
  70.         private void button2_Click(object sender, EventArgs e)
  71.         {
  72.             try
  73.             {
  74.                 label2.Text = RoundDownExplained(double.Parse(textBox1.Text), int.Parse(textBox2.Text) + 1).ToString();
  75.             }
  76.             catch (Exception)
  77.             {
  78.                 MessageBox.Show("Error ! Please check values.");
  79.             }
  80.         }
  81.     }
  82. }




Saturday, July 31, 2010

Error Accessing Path

Today is a day full of errors, when I fixed one error another error came while trying to run my hosted application. This time it was “Access to the path 'C:\inetpub\wwwroot\……’ is denied.

Full error is as follows,

Access to the path 'C:\inetpub\wwwroot\Mining2 Setup\Images\temp\tempImage.png' is denied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\Mining2 Setup\Images\temp\tempImage.png' is denied.

image_thumb[2]

The issue here was generated by a code written in my application which tries to access an image named tempImage.png in the said folder (Images\temp).

The reason for this is when you install IIS 7 the account used by the application pool (IIS_IUSRS) is not given access to the folder Images\temp. Since it is created by the application I just installed.

To sort out the issue give write permission to the folder Images\temp for the account IIS_IUSRS using the security tab in the folder properties page.

image_thumb[4]

Friday, July 30, 2010

Error when Installing MSI

Recently when trying to install a setup I made for a project on a new server having Windows Server 2008 R2 I continuously encountered an error as of below.

“The installer was interrupted before “Application” could be installed. You need to restart the installer to try again.”

image_thumb[2]

The server had IIS 7, .Net Framework 3.5 and 4 installed. After putting in some time onto this I found out that this is because the II6 Management Compatibility services was not installed for the Web Server role.

To fix it simply open the Server Manager and open up Web Server role and click on Add Role Services.

image Then select IIS 6 Management Compatibility node and all the child nodes below in under the Management Tools parent node and press next.

image When the installation is complete the setup will work as desired.

image_thumb[4]

Friday, July 23, 2010

Changing the Control Style at Runtime using the ASPX

Recently I changed the style of some controls in my ASPX page at runtime based on the values set on another control in my page. For example the color of the table is changed based on the radio button that was selected and the color of the button is changed according to the text that was typed in the textbox. Hope this is helpful.





  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head runat="server">
  3.     <title>Changing the Control Style</title>
  4.      <style type="text/css">
  5.         .Style1
  6.         {
  7.             background-color: Red;
  8.         }
  9.         .Style2
  10.         {
  11.             background-color: Blue;
  12.         }
  13.     </style>
  14. </head>
  15. <body>
  16.     <form id="form1" runat="server">
  17.         <asp:RadioButton ID="RadioButton1" runat="server" Text="Red" GroupName="1" Checked="True" AutoPostBack="True" />
  18.         <asp:RadioButton ID="RadioButton2" runat="server" Text="Blue" GroupName="1" AutoPostBack="True" />
  19.         <!-- Styling the table based on the radio button selection. -->
  20.         <table class="<% if(RadioButton1.Checked) { %> Style1 <% } else { %> Style2 <% } %>">
  21.             <tr>
  22.                 <td> &nbsp; See the change... </td>
  23.             </tr>
  24.             <tr>
  25.                 <td> &nbsp; </td>
  26.             </tr>
  27.         </table>
  28.         <asp:TextBox ID="TextBox1" runat="server" MaxLength="3"></asp:TextBox>
  29.         <!-- Styling the button based on the textbox value. -->
  30.         <input id="Button1" type="submit" value="button"
  31.                class="<% if(TextBox1.Text=="") { %> Style1 <% } else { %> Style2 <% } %>" />
  32.     </form>
  33. </body>
  34. </html>




Output looks as below.