Execute a method every time interval automatically c#

November 8, 2013 Leave a comment

To call a method automatically for every time interval, we can use timers in C#

See the code below.

class Program
public static System.Timers.Timer aTimer;
static void Main(string[] args)
aTimer = new System.Timers.Timer(10000);
aTimer.Elapsed += new ElapsedEventHandler(RunThis);
aTimer.AutoReset = true;
aTimer.Enabled = true;
private static void RunThis(object source, ElapsedEventArgs e)
Console.WriteLine("Print this in every 10 seconds");

Happy coding πŸ™‚

Setting up Visual SVN source control with Visual Studio and Tortoise Client

October 3, 2013 Leave a comment

My team faced many issues without a proper source control management.

Some issues are Team project, backup updated sources with different dates in folder, lacking update comments, etc

I got a cool svn server for managing different versions of source files. Visual SVN and its plugins for Visual Studio.

You can see here


Download and Install Visual SVN Server to setup svn server.

Download and Install Visual SVN as the plugin for your all versions of Visual Studio.

One more thing remaining. Download Tortoise svn client


Please install appropriate version, if your system is 64 bit, install 64 bit version.

Notes :

  • Install the svn server in a dedicated system with a particular port number (use https)
  • Make a repository to store your sources in the svn server, also make users (developers) to access the server.
  • Add solution to the svn server repository from developer’s visual studio.


  • Connect to server svn, its like


sandbox is the name of your repository. You can create many repositories in server.


  • After finish you can commit your solution, so it would be your first version of source code.
  • Many developers can work on that and make different versions of source with update comments.
  • Main things are Update and Commit

Update : Get updated source from the repository

Commit : Update (with comments)Β  repository with your new version of source code

Happy coding with svn πŸ™‚

Restore Database to SQL Azure

August 21, 2013 Leave a comment

Hmm.. i spent some hours to get a nice tool that exports our local database to Windows Azure SQL Cloud πŸ™‚

Here it is


Some screens to export the db





Put your sql azure credentials here


Connect – Wait the process to complete – Done


Categories: Azure Tags:

Ajax call before form submit asp.net c#

July 28, 2013 4 comments

Let me share an issue i faced.

I have a textbox with google auto complete plugin.


I need to store the place i typed in, its latitude, longitude in to the database.

So google have the javascript api to get the latitude and longitude, but it should be called before the form button click to store that in Hidden fields(my way), so i can get the values in server side(c#).

I tried the OnClientClick, but the hidden fields are not set with lat and long. The form is always submitting before the result is came from the ajax call :(.

I found a solution.

var geocoder;
function SetLatLng() {
geocoder = new google.maps.Geocoder();
           var address1 = document.getElementById("location1").value;
geocoder.geocode({ 'address': address1 }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
return false;
<asp:Button ID="FirstButton"Β OnClientClick="SetLatLng(); return false;" runat="server" Text="Click" />
<asp:Button ID="SecondButton" OnClick="buttonSubmit_Click" runat="server" Text="Click" style="display:none" />
<asp:HiddenField ID="HFLat" runat="server" Value="" />
<asp:HiddenField ID="HFLng" runat="server" Value="" />

Make 2 buttons, one for running the javascript, if the value is returned from the ajax call, click the second button programmatically πŸ˜›

Happy coding πŸ™‚

How to set up virtual port windows 7 c#

July 25, 2013 Leave a comment

Its really cool to have an emulator to set up virtual port in windows 7/XP

A null modem emulator, get it from here


You need to make paired ports to test the data send/receive

Follow the steps below to set up and test the virtual port.

1. Install the null modem emulator (com0com) as Administrator

2. Run the Windows 7 command prompt as administrator

3. Type the following command and hit enter

bcdedit.exe -set TESTSIGNING ON

4. Reboot the computer

5. Open the program com0com setup to configure virtual ports


6. Create paired ports, So we can test the data transfer. If any data we push to COMA, we can get it at COMB

7. Useful program to test the data transfer between ports is hyperterminal. Unfortunately its not in the Windows 7, its in XP i guess.

You can get the hyperterminal here http://sdrv.ms/15NJAMo

8. You can test the data from the hyperterminal as below


If you type something in COM A, you can see the text in COM B and vice versa.

Also you can manage the virtual ports from your c# code with SerialPort tool as well.

Happy coding…:):)

Awesome plugin for multiple file upload ajax asp.net

July 2, 2013 Leave a comment

Got a simple and nice plugin for uploading multiple files.


Here is my source code http://sdrv.ms/121hk6G

You can see detailed options here : http://www.albanx.com/ajaxuploader/examples.php?e=2

Happy coding πŸ™‚

Markers on map javascript asp.net c#

June 27, 2013 Leave a comment

Sometimes we gets trouble to mix Javascript and C#.
Here is my asp.net source to display dynamic markers on google map.


See live here


I called an aspx page to get some places as C# List, and convert the list to Javascript array from the ajax result.
So we can show markers on map using the normal google api functions.