Forum

Guys, Here is a forum for you. Just drop any Suggestion, Query, Problem anything here. I will try to solve it.
Please make sure that you properly point out your problem clearly, so that it is understandable to me.

If you are about to ask technical question make sure you put your code-snippet to your post (if it needs).

Thank you so much.
Shout it Submit this story to DotNetKicks Bookmark and Share
Read Disclaimer Notice

132 comments:

Sachin Sarma said...

Hi Abhishek. its nice to see your site. Its cool.

One question from me :
What is meant by delegates. I am little confused about the concept.

can u make it clear to me.

Abhishek Sur said...

Delegates you may say is a pointer to a function. Say you want to send a method to another class. you can only do that using delegates. Delegates allows you to send methods as argument to another method.

Notably you can use Lamda expression to represent delegates which are derived from Func or similar to them.

So you might take the help of annonymous methods to define a delegate using lamda expressions.

Check my article

http://www.codeproject.com/KB/dotnet/LINQ.aspx

Here I have discussed the basics of delegates and lamda expressions. I hope this would come handy to you.

Events are strongly related to delegates as events calls an external method directly from within the code. We expose an event which allow you to use a delegate to send method called eventhandlers to that event.

Thus when we raise an event from a class, we actually call the handler which will later be added to that event as Eventhandler. Instead of directly calling the method, we use the concept of event so that it will only call the method if the method is defined in the caller environment(the class which is using it). Therefore you can see use of events can only be possible with delegates as we are going to assign a method to an event.

visalakshi Subramanian said...

hi,
i m visalakshi from bangalore. i m working in a web team as technical. in our site we

implement the google map concept. I need some information and the procedure about

adding the tabs in the content box when we click on the marker.

for sample http://geo.worldbank.org/(when u click on the markers, it will display with the

tab) .And when i entered the codings of example 1: getting started, in html format in

notepad and executing it. the map is not displayed. it is just a blank page. can i know

where i have done the mistake.

these informations will help us to move forward. looking to hear from u as early as

possible. thanku for the time and consideration.


cheers.

Brian Doetsch said...

I'm really sorry to bother you but I've been trying for two days now. I am currently trying to follow your example at http://www.codeproject.com/KB/cs/BingSearch.aspx and I am cannot go past this error


using (LiveSearchService service = new LiveSearchService())
{

The type or namespace name 'LiveSearchService' could not be found (are you missing a using directive or an assembly reference?)

Assume this is where I went wrong: because I do know to how to create one.
now create an object of |LiveSearchPortTypeClient| which is the basic Endpoint class.


- Brian

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;

using WindowsFormsApplication2.BingService;
//using WindowsFormsApplication2.net;
//using WindowsFormsApplication2.Search;
//using WindowsFormsApplication2.BingSearch;

// SOAP
//http://api.bing.net/search.wsdl?AppID=0337DE28456CF974C8134A32023E3F6DE4622D60&Version=2.2
//http://api.search.live.net/search.wsdl?AppID=0337DE28456CF974C8134A32023E3F6DE4622D60




namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

// Replace the following string with the AppId you received from the
// Bing Developer Center.
const string BingMapsKey = "0337DE28456CF974C8134A32023E3F6DE4622D60";




private void btnTranslate_Click(object sender, EventArgs e)
{
string strTranslatedText = null;
try
{
TranslatorService.LanguageServiceClient client = new TranslatorService.LanguageServiceClient();
client = new TranslatorService.LanguageServiceClient();
strTranslatedText = client.Translate("0337DE28456CF974C8134A32023E3F6D7E8E0669", txtTraslateFrom.Text, "es", "en");
txtTranslatedText.Text = strTranslatedText;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private void button1_Click(object sender, EventArgs e)
{
}
public string SearchOutput(string AppId, string query, int offset, int no_of_res)
{
using (LiveSearchService service = new LiveSearchService())
{

try
{
SearchRequest request = new SearchRequest();
request.AppId = AppId;
request.Query = query;
request.Sources = new SourceType[] { SourceType.Web }; //You may specify multiple
request.Version = "2.0";
request.Market = "en-us";
request.Adult = AdultOption.Moderate;
request.AdultSpecified = true;
// request.Web = new WebRequest();
//request.Web.Count = no_of_res;
//request.Web.CountSpecified = true;
//request.Web.Offset = offset;
//SearchResponse response = service.Search(request);
// return GetResponsestring(response);
}
catch (Exception ex)
{
return ex.Message;
}
}
}







}



}

balaji said...

hi abi,
i have seen ur article about how to send mails from our windows
application...


actually i downloaded ur application source code and try to use it but
i got few runtime because of i was working in proxy enabled machine

after i turn it off it worked once but after i did not worked and i
throws error like"smtp unhandeld exception"



my coding is

name spaces are
using system.net.mail;
using System.Net.Mime;
private void button1_Click(object sender, EventArgs e)
{
try
{
SmtpClient server = new SmtpClient();
server.Credentials = new
System.Net.NetworkCredential("xxxx@gmail.com", "password");
server.UseDefaultCredentials = false;
server.Port = 25;
server.Host = "smtp.gmail.com";
server.EnableSsl = true;
MailMessage message = new MailMessage("xxxx@gmail.com",
"yyyy@rediffmail.com");
message.Body = "i love u";
message.Priority = MailPriority.High;

message.Subject = "my own mail ide";
server.Send(message);
}
catch (SystemException SE)
{
MessageBox.Show(SE.ToString());
}
}


and i'm gettin error is

System.Net.Mail.SmtpException was unhandled
Message="Failure sending mail."
Source="System"
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Gmail.Form1.Button1_Click(Object sender, EventArgs e) in
C:CoolCode_srcC_GmailGmailForm1.cs:line 45
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.
UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int3
2 reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Gmail.Program.Main() in
C:CoolCode_srcC_GmailGmailProgram.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()










pls tell to resolve tis problem man.i'm trying tis from last 1 month
....

i'm waiting for ur reply ...reply me as soon as possible

Marselle Nabil said...

Good morning sir,

I saw your application "Basics of Bing Search API using .NET" on the CodeProject.

It's very good.

I'll be very pleasured if you could help me in the following problem :
After displaying the search result , I want to navigate to any selected URL.
what can I do?

Thanks in advance.

Abhishek Sur said...

When user selects the item in the list, it will generate Selected Event on the ListBox.
Now from the ListBox, find the SelectedItem.

var item = lstBox.SelectedItem as WebResult;

now you could easyly open the link (item.Url) in IExplore or any web browser, or you can place WebBrowser control and navigate to that.

Actually you only need to find the WebResult object when listbox item is selected.

I hope this would help you.

Regards

Alochan Purohit said...

Dear sir,

I went through article on code project.com. http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

It is really very very much helpful.

I am a GPS application developer and looking for solution for movement analysis. I want to draw history points on google map but in a movement style. I am able to place 100 points at a time on map but not able to show them in a movement kind of appearence.

My sample code to draw more than one points on google map is shown below:


//==== Clear old layers

map.clearOverlays();

//=====================//

var Array_LAT_LON_DATA = new Array();

Array_LAT_LON_DATA = LAT_LON_DATA.split(
'@'); //=== It is collection in form of string

LAT_OLD = 0;

LON_OLD = 0;

for(i=0; i < Array_LAT_LON_DATA.length - 1; i++)

{

var Array_LAT_LON = new Array();

Array_LAT_LON = Array_LAT_LON_DATA[i].split(
'#');

var var_TIME_RECORDED = Array_LAT_LON[0];

var var_LAT = Array_LAT_LON[1];

var var_LON = Array_LAT_LON[2];

var var_STATE = Array_LAT_LON[3];

var var_SPEED = Array_LAT_LON[4];

LAT = Array_LAT_LON[1];

LON = Array_LAT_LON[2];
//, LON, LAT_OLD, LON_OLD;

STATE = Array_LAT_LON[3];

SPEED = Array_LAT_LON[4];

createMarker(var_TIME_RECORDED, LAT, LON, LAT_OLD, LON_OLD, STATE, SPEED); //=== Function to create marker.

// It is working properly. No issue here. Simple use of addOverlay function.



pausecomp(10000) ; //=== I tried to put some delay here... but no useless.



LAT_OLD = LAT;

LON_OLD = LON;

}


Please suggest me solution.

Abhishek Sur said...

Hi Alochan,

If you want to deal with large number of markers in a single page, I think you need to go for MarkerManager class already provided with GMAP. You can manage your markers, clear all markers and group common markers using this Collection.
The javascript you have provided looks good, but I am not sure why you need to pause for 10000. If you are not calling external services like GeoCode address or any other, I dont think any delay is required. Generally markers are loaded instantly just calling addOverlay.

If you are using services like GeoCode, ReverseGeoCode etc, you also need to do the rest of the logic within the Callback rather than going for arbitrary delay in the script for certain fixed value.

You can read more on MarkerManager from :
http://www.svennerberg.com/2009/01/handling-large-amounts-of-markers-in-google-maps/

Regards

Jon Miller said...

Abhishek,



I would like to add a goggle map to an asp.net c# website where a list of address to be shown would come from a mssqlserver. Your tutorial on codeproject is very good.

Would you be interested in helping me with this page? The sql db would containg lat, long and some text fields to display when the locator is clicked.



The scope of the locations is USA and Canada.



Thanks,

Jon Miller

Abhishek Sur said...

Hi,

You only need to fetch data from database and show as marker in the map. Boundaries doesnt matters, as a matter of fact, US and canada will have support of StreetView as well.

Please let me know what problem you are facing while fetching the data from database and show in map.

Regards

Jon Miller said...

Thanks for taking the time to reply.
Would it be slow if markers were added by street address instead of lat, lon?
I have all the street addresses but not coordinates.
Jon

Abhishek Sur said...

Hi John,

see, Gmap only supports the marker to position based on the latitude and longitude. Sometimes we need to geocode address to get latitude and longitude of a position. This comes handy with GeoCode API supported with GMAP. But this is time consuming. Gmap allows you to access geocode api through an AJAX callback. So for each address the Google server needed to be hit to get the appropriate callback. So if you have hundreds of addresses to be geocoded to show the map, it will create 100 of AJAX calls to Google servers. And hence it will hamper performance a lot.

If you want to show only one address at a time, you can use Geocode api and you can go with your address, but if you want all your addresses to be shown to the map, this would not be a good idea to do. I think you must have lat / long in the database as well.

Jon Miller said...

Good advice. I will add lat/long to our db.
Jon

vijay said...

Hi Abhishek ..... This is vijay,i got your project coding in code project for sending mail using gmail account in windows application.... It quite good and perfect.... i tried in the same way to send mail using my yahoo id.... Its not working.... What are the steps i should follow to get the solution....Reply me even u r busy... have a good day man thanks alot....

Abhishek Sur said...

Hey Vijay,
Basically it is very easy to work with yahoo mails. For Yahoo you need to connect to
smtp.mail.yahoo.com

And the port no is : 465

Charles took my code and did a great job by making an application to work with Yahoo, Live and most of the other services, you might try that for you as well :
http://www.codeproject.com/KB/cs/GmailSmtp.aspx

I think this will definitely help.

Thank you vijay. Let me know if it solves the issue.

Anonymous said...

Hi Abhi
I am having an issue with visual studio 2005.
I am using VSS with visual studio 2005. I have checked out file and made few changes yesterday and without checking in the file i have closed VS 2005(as i do normally). But today morning when i opened the project in Visual studio, i got a message stating that "Unable to load one or more break points" and when i saw the file, it has been overwritten by vss copy and i lost all the changes i made to the file. What could be the reason? This is the 3rd time i got this issue and i am posting here.

Thanks in advance
Naina

Anonymous said...

Hi Abhi
I have a fileupload control in asp.net page
I also have update panel in the page.

Now when i try to browse a file and check for the filename using fileupload.FileName, it shows empty.

When googled it gave an answere that fileupload control will not work in updatepanel. But i have the same code in another page with updatepanel and it worked. What could be the differance?

Abhishek Sur said...

You need to use PostBackTrigger to do this. Actually AJAX object cannot upload data from the File System. So either you have to rely on normal postback, or use browser plugins like Flash, Silverlight etc, which supports to access file system directly.

Yuri Rubinov said...

Hi,

Sorry for contacting you directly. After reading your articles about Excel files as data source I believe that you can give me some hints.

What is the best way to collect data from several Excel sheets belonging to different Excel files? Those sheets are logically related to each other and contain key fields that allow to find matching records.

Say, is it possible to create one connection and then in one select statement gather information as if those sheets are tables in one database?

I believe that the technique is similar to whatever programming language I currently use, Excel VBA, VB.NET or Visual FoxPro.

Advanced question is what if Excel files were created in different Excel versions, say, 2003 and 2007?


I hope that you will not consider it as a rude call.


Thank you in advance



Yuri Rubinov
Senior Systems Analyst
Sunoco Inc.
1735 Market Street, Philadelphia PA 19103-7583
(215)977-6537

Abhishek Sur said...

Hi,

See, if you are about to join two or more files you can do using one select statement. You might go for OpenRowset to connect any file from your sql query as well. You can try google around with OpenRowSet in sql server, to get the information about it.

Otherwise, (more recommended) You can use Interop services for Excel. Interop is modified in .NET 4.0 with more flexibilities and version problem been cleared out. Read data using interop.

By any means you use, in those cases, all the files needed to be connected simultaneously.

Anonymous said...

hi i am rajashekar, i have one requirement that when user enters their gmail id and password in my asp page, we have to show his gmail page.
As how we enter user id and password from "www.gmail.com", whenever we enter correct password it has to open their mail.How can we achive it using asp.net and c#.

Abhishek Sur said...

Hi Rajashekar,

Well if you want to invoke an external request to www.gmail.com, why dont you use an IFrame and navigate your page directly from the browser itself. Once the authentication is sucessful it automatically redirects to the mail server.

This is the most easiest way to handle and probably the only way, as Gmail server puts on SSL connection and you need to have direct connection from the browser to the server to ensure that SSL works fine while you login.

Please let me know the proceedings.

Thanks

Anonymous said...

How to translate my whole website?

Am having some products in that website, so I need to translate my website for my customers, without irritating them as well I should help more if It will a end user.

Narendran.
narenselva89@gmail.com

Abhishek Sur said...

Hi Narensalva,

There are a couple of options which is available for you.

1. To create your website in such a way that it automatically detects the Client Culture and present the page accordingly from the server using Resource files.
ASP.net already supports such kind of things.
Have a look into :
http://www.c-sharpcorner.com/uploadfile/mosessaur/aspnetlocalization02042006165851pm/aspnetlocalization.aspx?articleid=96602e53-0fb1-44ec-a67b-1c68b05eb2e1

2. You can put a plugin which will be added in the client side and provide you the translation of the whole page from the clients end. One that I have added to my site is Microsoft Translator widget, which is available for free.

http://www.microsofttranslator.com/?ref=MSTWidget

I hope you can take any option. For an application I generally prefer the first option.

Thanks

Anonymous said...

Hai Sir,

Thanks a lot for ur kind information...

NarenSelva.

vineet said...

Hi Sir i am vineet
First of all i would like to thank you for the great work.
I have downloaded ur code "How to send mails from ur gmail account" i want to use ur code on an exchange server please give me an overview of the procedure.

Abhishek Sur said...

Why do you require gmail for exchange server. Configure your application to use your own exchange server settings, check what type of credentials you need. You dont need to authenticate using Gmail, rather you just change the SMTPServer settings from my code.

I hope you can do the same.

Jaysuriya said...

I don’t know how to open a downloaded template in visual studio 2005.will you please send me detail regarding above query at jayasurya.manakkadampallil@gmail.com

Abhishek Sur said...

Hi Jaysuriya,

Well, I think I have already discussed where to place them. Place them in Templates folder under your Documents\Visual Studio 2005.
The templates are of type ItemTemplate and Project Templates. Place in appropriate folder and run Visual studio. I hope you will get what you wanted.

sun said...

Hi Abhishek,

I am using Bing maps using javascript and reading JSON object to display the data. Every thing works fine. But how can I use Bing API in my app? I am posting part of the code. Please let me know how to slove this.

The following is working fine.

script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"

------------------------------------------------
this is my API 01D8BB126E95D11193A267D628860F274B6888BD.. How can I use this in the application??

sun said...

Hi Abhishek,

I am using Bing maps using javascript and reading JSON object to display the data. Every thing works fine. But how can I use Bing API in my app? I am posting part of the code. Please let me know how to slove this.

The following is working fine.

script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.3"

------------------------------------------------
this is my API 01D8BB126E95D11193A267D628860F274B6888BD.. How can I use this in the application??

Abhishek Sur said...

Hi Sun,

Well, did you see my article on Bing Map in Codeproject ?
VEMap Demo

I think I have explained everything there. Just read the article and try out the examples to create your Bing map.

Anonymous said...

Hi
Am new in WCF and am trying do something in Dynamic Linq and WCF ,
My project is according to whatever condition given it must fetch data from Sql2008

when i pass condition like

strCondition=("Active='I'")

Now my getting the error

Operator '==' incompatible with operand types 'char ?' and 'String'

am getting this error when converting from LINQ

PLz help me

my mail id is

balaswari.a@gmail.com

Abhishek Sur said...

@Annonymous,

Can you show me the entire code.

How about
strCondition = string.Format("Active='{0}'", i);

I hope this would work better.

darshan said...

Dear Abhishek,

I gone through your profile and blogs and found that you can help us with our some IT related problems.

We are working for project called "Ahmedabad 4 World Heritage City"
You can visit us on facebook : "Ahmedabad4whc".

we are planning to make custom map of heritage ahmedabad with some extra features as under.

> limited dragging or panning of map for ahmedabad only
> Minimum Zoom level
> customized layers side bar for user to select categories or place marks of their interest from all.
> Easy adding of new place marks and defining it to particular layer
> auto routing for selected POIs
> logo of our organization at the left bottom of map.

Features in bold are already achived. i have you code for that on your gmail and yahoo mail both.

Please help us to develop other features as mentioned above.
Please reply soon.

Thanks and Regards
DARSHAN BRAHMBHATT
AHMEDABAD

Anonymous said...

Hi abhishek,
i would like to know is there any way to access wcf (net.tcp binding) from java client.

Abhishek Sur said...

@darshan

Did you see my complete article on Google Maps :
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

I am sure this will help you.
Actually everything you do in your map should be transferred to the server using AJAX as GMap api exposes javascript object so it is totally rendered in client side.

Check my article, i think you will get most of the requirements.

:) Sorry for late in reply. I was in a holiday for last few days.

Thanks.

Abhishek Sur said...

@Annonymous

NetTCP/NamedPipe are not interoperable with other clients. They are proprietary protocol which optimizes communication between two WCF apps.

I think it is better to go with WSE interop with WCF to work with JAVA clients which already supports Binary data traversal or even stremed.

darshan said...

Dear abhishek,

But the big problem is that i am not an IT guy.
so coding is just like a mystery for me. so please help me with code or direct me to the person who can write code for me please.

Thanks
DARSHAN

Rajesh said...

Hi Abhishek,
Your article Folder Protection is good but there
a problem when rename,protection break.
So,how can disable right click because user can not make rename.
Please give answer when u get time my eid-shiv19rajesh@gmail.com

Rajesh said...

Hi Abhishek,
Your article Folder Protection is good but there
a problem when rename,protection break.
So,how can disable right click because user can not make rename.
Please give answer when u get time my eid-rajesh.mca19@gmail.com

Abhishek Sur said...

@darsan,

I am sorry I cant help you. But I would definitely try to find one person for you. I am out of time now but will try to solve or give you an alternative on the same.

Sorry for late in reply.

Anonymous said...

Hello Sir

I m vikram patil software developer from pune.i want to use wcf in my Application .I have a some question on this

1)Why and at which situation we use WCF?
2)What is Diffrent between WCF and asmx service
3)Suppose i want to use REST based service which return in JSON format in my Applicattion.How i can call this service from using JQuery ajax function
4) I Create a one REST based service and it is used in my application .i give the call this service from JQuery but it doesn't work .

Abhishek Sur said...

Hi Vikram,
Nice to hear from you. Well coming to your question:

1. We use service when we want out utility to be available to more than one client or in other words when we want to publish our operation as service which is available to outside world. WCF is an extension of normal web service.
2. ASMX service works only with BasicHttpBinding, it does not support WS*. It can only use SOAP based messages. Even SOAP extensibility allows you to extend your web service to allow encryption but still the body is strict to the w3c standards. WCF on the other hand breaks apart the rules and regulation and allowing you to use any kind of binding like TCP / NamedPipe / MSMQ etc. and helps you to work with any of these.
3. Services are to run on the server and produce output. REST approach makes the service more representational and hence allow you to invoke the service from your browser. JQuery allows you to parse the XML or any JSON object which the service returns, there is no connection between the actual service and JQuery.
4. Did you call the service properly. You need to use AJAX to call the url.

I hope this would help

Anonymous said...

@Abhishek
This is helpful for me .

My another Question is that if i create REST service in one application and use this service in other application then it is work? .
Please tell me a details about SOAP.
I attached my demo application here that create for the REST service.I m beginer in WCF so something is wrong in this Application.I make ajax call in this Application but it doesn't work.
If you have some demo application on WCF for beginer please send me.

Once again thanks for helping.
Vikram

Anita Seymour said...

Hi Abhishek,

My name is Anita and I got your email from codeproject site after reading your article on Restful Crud operation on a WCF service – which was very well written! I have been researching a lot on the web for WCF examples that allow for CRUD and was very happy when I found your article. I did have some questions that I haven’t been able to find a satisfactory answers to.

We have a need to create an application that will consume the WCF web service using javascript to run on different mobile devices ie. Android, Blackberry, iPhones, etc. The application will work like a native application in the sense that they will be able to work in it even if there is no data connection. My concern is data security. If we host the web service through IIS and open port 80 – it’s open to the world. All web services need to follow the same orgin policy and in our case we have a need for cross site access so CRUD operations can be performed. In this scenario how do you recommend setting up the web service so it is available to the mobile clients without compromising security? I would love to hear your recommendation and how you would approach this. It sounds like you are very experienced and may have a good solution for me J

Thanks in advance for your time.

Thanks,
Anita Seymour

Abhishek Sur said...

Well Anita,

It is always been a common headache when dealing with mobile devices like android, blackberry, iphones as most of them does not support Web service extensions. REST is very helpful when you are calling the service from Browser as it can invoke HTTP requests easily.

For your application, I think it is better to check the device from the server. Allow your application to register to your server with its unique identification something using IMEI number. Now when you are calling from those devices always put the IMEI number and UID and pass in the header as encrypted string. You can generate an MD5 auth string during the registration process to uniquely identify the user, and store the same in both server and device. Always send this string to the server from your mobile with IMEI number, UID and pass to authenticate.

Now the server knows which calls to respond based on the MD5 hash which could not be decrypted, and also the UID and password that matches for some specific device.

This is just a thought, as if I would be in your place, I would demonstrate the same to my people.

Regards

darshan said...

Dear abhisek,
Please help me with the person or some tips for coding so i can complete the project sooner.
our organisation is pending with this map only now.

DARSHAN

Abhishek Sur said...

@darshan Hey, but what is the problem you are facing? Couldnt you build the Google app ?

It is quite easy I think, did you try my samples ?

Just try to edit the javascript and find out what is happening. Please let me know if you are successful in this.

Regards

Anita Seymour said...

@Abhishek SurHi Abhishek,



Thanks so much for taking the time to write back! I really appreciate it. Will this also work for clients connecting using laptops, tablet PC, etc? As I am new to this technology would you be interested in helping me implement this? If yes, what is your rate? If no L would you be able to recommend resources, books, websites, tutorials, etc?



Can Restful support returning JSON data?



I look forward to your reply. Thanks again!

Abhishek Sur said...

@Anita Seymour

Yes Anita, Restful supports JSON. There are lots of tutorials around, you can take a look into google for links and tutorials.

Ahrex said...

Hi Mr Abhishek Sur,

May I ask you about the sending mails through Gmail code? My question is can I do it without a UI? My program(all using c#) is basically like this:

1) Connect to a GSM modem.
2) Receive SMS and execute webcam to take picture upon receiving SMS.
3) Picture taken is saved to computer.
4) Send picture to email automatically <--- How do I do this automatically without any UI?

Hope you will have some time to look through this e-mail. Looking forward to your reply.

Abhishek Sur said...

@Ahrex
Yes, there is no need as such for UI to send an email. Just replace the textboxes with actual email ids, userid and password and execute in background. No need for an UI.

Ahrex said...

Hi Sir,

Thanks for your reply. It means a lot to me. Can i ask you 1 more question? Is it possible to send an e-mail with attachment automatically, like every minute? What I mean is the program will be run in the background and can I program it such that it will scan a folder that I specify and attach a file and send it as an e-mail every minute?

Abhishek Sur said...

Well,

Yes you can send as many mail as possible and also with attachment, but to remind you, if you go on sending so many mails, google mail server will detect you as a spammer and ultimately stop sending. This is there with google server as many people misuses it. But if you are using your own SMTP server, it will be no problem at all.

I hope this answers your question. Happy programming.

Jignesh said...

Hi Abhishek

How are you?

This is Jignesh Patel. By profession i am a software professional.

I read your article and was very interesting. Thank you very much for such a nice article.

I would like to know if we can bind the dynamic data to the Google Map.

E.g. XYZ compnay has a 5 different locations and this location comes from database. Now i want to show this location in the google map. These locations could be changed. So may be next month XYZ get more locations.

So could you please help me how to find this dynamic data with the google map.

Looking forward to hearing from you.

Abhishek Sur said...

@Jignesh

If you are using asp.NET, just load the locations into a hidden field and access the hiddenfield from your javascript.

Parse the data and show the marker.

Regards

Jignesh said...

@Abhishek Sur

Thank you very much for your favourable reply.

Let me clarify the steps again that i will do:

1) Fetch the data from Database in Serverside
2) Access the Hidden field in the Server side and will store the location value into the Hidden field
3) Access the Hidden Filed in the JavaScript
4)Parse the value to show the marker.
Is there anything i have to add the reference in order to access the google map?

Thank you very much once again for your wonderful support.

Abhishek Sur said...

@Jignesh

Actually Google exposes a Javascript API, so you do not need to take reference of any external dlls to work with it. As you can see in my examples in the article, I have already placed few points over the map, even example 8 invokes ajax request to get points from server to produce the points.

In your case if you want to do this using normal database call from your aspx page, you can do either by loading those points in hidden control and parse it from your client side code using simple getElementById calls to those controls and draw the marker in the map.

Otherwise, you can produce the XML(or any other format, probably JSON) in a handler in the server side, and call the xml data from your javascript using AJAX, parse it and load the marker. The technique entirely depends on your choice.

Gautam Kumar Kanaujia said...

I had seen your blog at the code project site as given below,really it seems very good but I could not understand how can I relate with old objects.it looks like generics in C#.

I am working in C# 3.5.Can I take advantage of this in 3.5 framework?

http://www.codeproject.com/Articles/125121/Working-with-Tuple-in-Csharp-4-0.aspx

Abhishek Sur said...

@Gautam Kumar Kanaujia

Actually the class is actually with .NET framework BCL. So it will not be available with .NET 3.5. But this is no big deal, you can create the same yourself.

Just create a class with as many parameter you need and then expose those. Simple enough to do.

Thank you.

Mohamed Harish said...

Dear Mr.Abhisek,
I have installed visual studio 2008 express edition.When i start to create a windows based as well web based project,most of the template are missing.For the past one week i tried in online but nothing works for me.How can i install the missing template in my visual studio 2008.I would be really happy if you can help me about this issue.

Abhishek Sur said...

@Mohamed Harish

I think either you reinstall the application or try to find the templates.

Templates are installed in your MyDocuments. It should be there under Visual Studio 2008 folder of your documents folder. Please check whether they are missing or not.

Chandan Patra said...

Dear Abhishek,

I just went thru your profile at http://www.abhisheksur.com and I was impressed. I am a commerce graduate, and I always had a dream to become software professional some day, but somehow the dream was far away. I joined life insurance sector, but after working there for 2/3 yrs, now at the age of 32 I got a opportunity to work in IT; Currently I work with VB6, HTML, JavaScript and PHP, but just like you I was very fond of C, C++ which I had learnt in my DOEACC A level course. I checked some of your C codes, they are very beautiful. I am still eager to code in C, C++ but opportunities are limited.

I just want to ask you one question.. What technology/language I should learn so that I can make lots of system/application softwares at low level. Sometimes it really confuses me as which language I should know first, c# or Java? I want to learn the low level things just the way u started your career. Any suggestion will help me a lot.

Thanks and regards
Chandan Patra
Kolkata, WB

Abhishek Sur said...

@Chandan Patra


Actually I started my career from C the C++ etc. But those are days of my college life. In my work, I work on .NET technology. If you are thinking of making money, then I would recommend to work with .NET or JAVA. If you are doing it just for fun, Assembly languages could be a good choice. You can even interop few API's from .NET too (May be try VS C++)

Anantha Krishnan said...

Hi,

I saw your post in codeproject its awesome. I've one doubt plz clarify me when you get time.

Can we host wcf service in webserver say aspspider.com?

Plz help me.

Abhishek Sur said...

@Anantha Krishnan
WCF is same as webservice when you have configured as BasicHttpBinding. Actually there is no restriction to WCF to host in any environment. I think it could easily be hosted with aspspider.com, even though I didnt tried it(it should be).

Anonymous said...

@Abhishek Sur

Hi Abhishek,

Thanks for your kind info and great help.

I tried hosting in aspspider.com

I'm getting some error like authentication="windows" It shld be an application some thing like this.

I'll send you the exact error soon.

Mean time I'll also try to find the solution for this.

Once again thanks for your help.

supriya chakraborty said...

Hi Abhishek,

I am just new in Google map api and I have to develop a application to show GPS data history.
I was trying to find out some samples and I found your nice article on codeproject.

I have the following requirement.
1. I have to show polyline with arrow.
2. Starting and end point should be a meaningful icon.
3. Clicking on marker icon I have to show info window. Info window content should be the combination of database data + reverse geocoding.
4. on mouse over on map I have to show Lat,Long in a textbox.

Can you help me to develop this things.

Waiting for your favorable response.

Abhishek Sur said...

Hi,

Based on your requirements:

1. Polylines could be drawn very easily using GPolyline Check
http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GPolyline.GPolyline

for API.

2. You can put any Icon using GIcon
http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GIcon

3. No issue, invoke Reverse Geocode when your Marker is opened. Use GDownload to download the response from the server and also put a reverse geocode request on. as both are asynchronous, they will work. On receive of both the requests, update the InfoWindow

4. I have done it already in my Example 6.
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx
Check out the online demo here :
http://techabhishek.bravehost.com/google.htm

Happy coding.

ripu daman said...

Hellow Boss,
Here Ripu Daman Maheshwari ! How r u? I m also keen to know .net technologies. But i need guidance from you.hope you would not disappoint me.
Hae a nice Evening.

Chandan Patra said...

Dear Abhishek,

I just went thru your profile here and I was impressed. I am a commerce graduate, and I always had a dream to become software professional some day, but somehow the dream was far away. I joined life insurance sector, but after working there for 2/3 yrs, now at the age of 32 I got a opportunity to work in IT; Currently I work with VB6, HTML, JavaScript and PHP, but just like you I was very fond of C, C++ which I had learnt in my DOEACC A level course. I checked some of your C codes, they are very beautiful. I am still eager to code in C, C++ but opportunities are limited.

I just want to ask you one question.. What technology/language I should learn so that I can make lots of system/application softwares at low level. Sometimes it really confuses me as which language I should know first, c# or Java? I want to learn the low level things just the way u started your career. Any suggestion will help me a lot.

Abhishek Sur said...

@Chandan Patra
Hi Chandan,

Actually I started my career from C the C++ etc. But those are days of my college life. In my work, I work on .NET technology. If you are thinking of making money, then I would recommend to work with .NET or JAVA. If you are doing it just for fun, Assembly languages could be a good choice. You can even interop few API's from .NET too (May be try VS C++)

Chandan Patra said...

@Abhishek Sur

Thanks a lot for your nice reply. I really feel the need to learn either Java or .NET. Surviving is also very important.

Abhishek Sur said...

@Chandan Patra

You are right.

devajit dutta said...

i am developing a Google map in our website. i already done G point. but i am unable to put tiles on Google map. plz help me.

Abhishek Sur said...

@devajit dutta
Hi,

Did you read my article already on Google Map. I think the examples does load GMap.

Check the article
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

I hope this would help.

Regards

Anonymous said...

Terrific work! This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!

G.Abir said...

Google Maps in HTML, ASP.NET, PHP, JSP etc. with ease
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

This is the best post i EVER see.
i need a option to my site to show customer location base on is registration information ,country, city, street......
i need to show root between 2 customer in the same city.
it is possible??
you help is appreciated
Thank you

Abhishek Sur said...

@G.Abir
Yes,

There is Geocoding API for that.
Check this link

http://econym.org.uk/gmap/example_multi2.htm

click on the map to get two points and click Get directions. You will get the direction. Now open the code in notepad and try.

Regards

Anonymous said...

I bit it was succeeding to be some unexciting old despatch, but I’m satisfied I visited. I thinks fitting register a tie-up to this site on my blog. I feel my visitors determination find that very useful.

Anonymous said...

Beneficial info and excellent design you got here! I want to thank you for sharing your ideas and putting the time into the stuff you publish! Great work!

Anonymous said...

Keep posting stuff like this i really like it

Anonymous said...

Good Day every one, superb chat board I find It incredibly useful & it's helped me out so much
I hope to give something back and support others like this site has helped me

_________________
[url=http://iphoneusers.com]redsn0w[/url]

Anonymous said...

I think one of your advertisements caused my internet browser to resize, you might want to put that on your blacklist.

Anonymous said...

Great information! I’ve been looking for something like this for a while now. Thanks!

Abhishek Sur said...

@Anonymous
Thank you for letting me know

Mark Gibson said...

Hi Abhi,

I have not had a chance to read back through all of your previous posts on the subject of programming information useful to .NET developers, but your explanation of basic looping constructs was clear and concise. I have been a programmer since the late 1970s, but haven't written much code in this century, at least not the kind of low-level HW interface and system level software that interests me most. My C++ code looks suspiciously like ordinary C code and I struggle to write C# code as it should be written. Bad habits come from enjoying .asm language programming enough to have been paid to do it...

Anyway, since you seem to cover a wide range of Computer Science and C# topics from fundamental programing concepts (e.g.: looping) to things which I want to learn more about such as casting, address space randomization, object notifiers, etc. that come part and parcel with .NET and the programming languages that target it, I'd like to know if there is a way to add all of (just) your .NET Tricks blog entries to date (as of say next Monday) to an RSS feed and continue adding them from about then onward, without including all the threaded replies. I just don't have the time nor the inclination to follow the complete threads for most of the blogs that interest me, but do like to skim the main entries and dig deeper or do further research on occasion. The main posts are enough to tell me where to start.

Thanks in advance.

Abhishek Sur said...

@Mark Gibson

Thanks mark.

Here is the link for my blog entry.
http://feeds.feedburner.com/~r/abhisheksur/WTgI/~6/1

ramesh kumar said...

Hello Abhi,

I have a requirement for a web page where I need to update the status of the user. I wonder how FB/twitter works.

As per my knowledge one simple way to do this is "making ajax calls to the server using java script setinterval function". But this will make huge calls to the server.

Is there any other ways to do this. My intention is to reduce unnecessary calls to the server.

Silverlight is out of box as plug-in installation required.

Please help here.

Abhishek Sur said...

See,

Push notification for normal webpage (which is disconnected from the server) is not possible, if you think of a situation where your application does not stop there are few options like COMET.

http://www.codeproject.com/KB/custom-controls/CometMultiClient.aspx

But let me remind you, its not an actual Server Push Technology. Here there is a major performance issue. The thread which is created in the server will not be aborted and keep on running and also it opens up an active communication channel between the two machines. But this is usable.

Other than that, you might use server call using SetInterval. To ensure you do not eat up server resources, you create a Cache entry for the data in some cache server. Call the server at an interval and check only the cache entry(may be through an IHttpHandler). When cache entry gets updated due to data change, you might get data to the client.
You can update Cache entry from SQL Server too :
http://www.codeproject.com/KB/cs/SqlDependency.aspx

BTW, there is another option too. You might also use Silverlight/Adobe Air sandboxed applet for browser which also opens up socket on both server and client, so that when server is updated, the client gets notified.

Anonymous said...

I'm newbie, hi

vishal patwardhan said...

Hi, I am using following routing in my asp.net mvc

routes.MapRoute(
null, // Route name
"Default", // URL with parameters
new
{
controller = "Home", // Parameter defaults
action = "Index",Id=UrlParameter.Optional
}
);

But unfortunately this showing me the directory browsing but if i write the url like localhost:port/Default then this is showing me the correct one.what should i do?

Anonymous said...

I thought I would drop in and say hello. My name is Sam. I am the owner of Uuom.com.

Anonymous said...

Hiya : )

You shop on the web or in-store? which would you go for? actually wondering lol.. i love in-store only because i hate waiting it to arrive!

Cheers
Madison

Anonymous said...

hi, new to the site, thanks.

Anonymous said...

tres interessant, merci

Anonymous said...

thanks for this nice post 111213

Anonymous said...

thanks for this tips

Srini said...

Hi Abhishek

I have gone through you r article in Code porject related to Google API, really i have learnt from that lot, i am developing the web application i want to use google api for my applicaiton, please let me know how to use google api with dynamic data from database, i want to add marker with different colorover the map based the data from sql database and also i want to draw a line(dotted line) in between to marker is it possible to do with google api.

Abhishek Sur said...

@Srini

Yes definitely, it is possible. One thing that you keep in mind that GMap is javascript API. So you need to call AJAX to get data from the server and point the markers accordingly.

Just see this example:
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx#agp

I am using an XML file stored in the server to get the data. You may use your webpage or may be load them inside some hidden field to do this job etc.

Thank you for your appreciation.

Anele Ngqandu said...

Hi Sir
Am a 3rd year software development student in South Africa and am interested on creating a street navigator application for my campus. Am looking for a starting point and a good advice. Please help

Abhishek Sur said...

@Anele NgqanduHi Anele,

I recommend you to read the article
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

where I have explained everything regarding Gmaps.

I hope that will help.

onder ozdemir said...

Salam brother i read your article at codeproject about google api examples
i am from istanbul Turkiye

i am working gas company and i must create line of gas way on google map and show animation of gas during that way as that example
http://missokhay.alwaysdata.net/animation.htm

can u halp me ?

Allah hafiz take care

Charles Huajie Wang said...

HI, Abhishek Sur
I read you article on codeproject.com about SqlCacheDependency
I tested a example ,but it doesn’t work,
private string ConnectionString =
ConfigurationManager.ConnectionStrings["dbConnection"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
return;

this.BindGrid();

}
protected void btnSave_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(this.txtTitle.Text) &&
!string.IsNullOrWhiteSpace(this.txtDescription.Text))
this.Insert(this.txtTitle.Text, this.txtDescription.Text);
this.BindGrid();

}

private void BindGrid()
{
DataTable dtMessages = (DataTable)Cache.Get("Messages");

if (dtMessages == null)
{
dtMessages = this.LoadMessages();
lblDate.Text = string.Format("Last retrieved DateTime : {0}", System.DateTime.Now);
}
else
{
lblDate.Text = "Data Retrieved from Cache";
}
grdMessages.DataSource = dtMessages;
grdMessages.DataBind();
}
private DataTable LoadMessages()
{

DataTable dtMessages = new DataTable();

using (SqlConnection connection = new SqlConnection(this.ConnectionString))
{
SqlCommand command = new SqlCommand("Select [MID],
[MsgString],[MsgDesc] from dbo.Message", connection);

SqlCacheDependency dependency = new SqlCacheDependency(command);

if (connection.State == ConnectionState.Closed)
connection.Open();

dtMessages.Load(command.ExecuteReader(CommandBehavior.CloseConnection));

Cache.Insert("Messages", dtMessages, dependency);
}

return dtMessages;

}
The problem is that
(DataTable)Cache.Get("Messages") is always null.

I found after I executed “dtMessages.Load(command.ExecuteReader(CommandBehavior.CloseConnection));”, the SqlCacheDependency notification immediately fired out, so the cache immediately got empty.

Could you please help me about this, or is the Cache.Get("Messages") always empty in your local test environment?

Abhishek Sur said...

@Charles Huajie Wang

You always need to use dbo before tablename.

You need use Select [MID], [MsgString],[MsgDesc] from dbo.Message" instead of
Select [MID],[MsgString],[MsgDesc] from Message

Mohammad Sallal said...

I am Mohamad Al sallal from jordan, am working on a project for data mining, i saw your project 'Working with MS Excel' at the link http://www.codeproject.com/KB/miscctrl/Excel_data_access.aspx?display=PrintAll#drop


it`s really great work, but there is a problem that when i try to retrieve the excell sheet, the message apper is "the 'microsoft Jet OLEDB.4.0' provider is not registered on"


am working with visual studio 2010 and office 2010

so can you help to solve this error please

Abhishek Sur said...

@Mohammad Sallal
For Excel 2007 onwards you need to use Microsoft.ACE.OLEDB.12.0 rather than 4.0

Anonymous said...

Hello.
The interesting name of a site - www.abhisheksur.com, interesting this here is very good.
I spent 5 hours searching in the network, until find your forum!

Anonymous said...

Hi

Anonymous said...

After exploring through the boards for some time I decided its time to join. I hope we can all get a long and share knowleadge.Iam looking forward to it. Let the fun begin :)

Anonymous said...

Hello.
The interesting name of a site - www.abhisheksur.com, interesting this here is very good.
I spent 5 hours searching in the network, until find your forum!

Anonymous said...

hi, good site very much appreciatted

Anonymous said...

hahahahahha nice 1

Anonymous said...

Hey Iam bad with introductions but I figured I could adleast say hallo too you all. :) Not sure what to say here .... I live in France and plan on shifting to the states soon. In a matter of fact Iam leaving to Chicago later this morning with my wife. I will be back in a 7 days if any one want ill post some photos:)

Abhishek Sur said...

@Anonymous

Its a technical site. Do not post any personal information here.

Anonymous said...

Hello.
The interesting name of a site - www.abhisheksur.com, interesting this here is very good.
I spent 3 hours searching in the network, until find your forum!

Anonymous said...

Hello, I new yours frient on this forum)

Anonymous said...

Hello. And Bye.

Anonymous said...

I think you may want to put a twitter button to your blog. I just marked down the site, however I must make this by hand. Just my 2 cents.

Anonymous said...

Hi Abhi,
I am new programmer, working in IT company (Pune)
I read your post on Google Map.
I like it. I want to ask you, if I have to display Google Map for our company location in its Website,How to do it?
I want to display placemark and company name in that map.
Avinash -Pune

Abhishek Sur said...

@Anonymous

Hey, have you tried my article ?
http://www.codeproject.com/KB/scripting/Use_of_Google_Map.aspx

It clearly explains this. Even I think you will find source code to do exactly what you want.
The only thing is to modify the lat/lon for your company, and it will work

Anonymous said...

I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.

Anonymous said...

Do you people have a facebook fan page? I looked for one on twitter but could not discover one, I would really like to become a fan!

Abhishek Sur said...

@Anonymous

You can use this :
http://www.facebook.com/pages/Dot-Net-Tricks/169441829773456

Anonymous said...

Admin, hello! here are having problems with your site. malware warning Write me. icq 989567856647

Anonymous said...

In all affairs it's a healthy thing now and then to hang a question mark on the things you have long taken for granted.

Anonymous said...

Hey im new here.

Nice to meet everyone!
Hope you all have a good day

Anonymous said...

Hey im new here.

Im sam, how is everyone?

I look forwards to being a active memeber

Anonymous said...

Hey im new here.

Im sam, how is everyone?

I look forwards to being a active memeber

Anonymous said...

Hello. Interesting site you have.

Post a Comment

Please make sure that the question you ask is somehow related to the post you choose. Otherwise you post your general question in Forum section.

Author's new book

Abhishek authored one of the best selling book of .NET. It covers ASP.NET, WPF, Windows 8, Threading, Memory Management, Internals, Visual Studio, HTML5, JQuery and many more...
Grab it now !!!