Thursday, 26 September 2013

How to create / use web service

For an overview, we create a webservice project and a website calling that web service.
Web service project looks like below and is under localhost

Web site looks like as below and is under c:\work.



Firstly, I followed the link below showing nicely how to create web service and use it.
http://msdn.microsoft.com/en-us/library/8wbhsy70(v=vs.90).aspx

I started following the link above and created a web service web application. My localhost inetmgr looks like below. I haven't changed any Advanced settings in IIS but just uploaded the capture here for future reference.





The web service is a small program changing F temperature to C.



If you mess up Application Pool you can get this error:

Otherwise, you can see the working page as below:

Then I launched the webservice to live server. This just meant copying whole folder from localhost to the server folder.

Once I change to live server from localhost, I got the below error:
It was because my folder on webserver was not set up as web application.

After changing it to Application, the web service URL starts working.
 But the F to C change function says, it only works in localhost.
 After searching on Google, i found that it's not error, but for security.

Web service is now working. Next step is to use it.
Create another website and call it. I couldn't find web reference, so i clicked 'Add Service Reference'.
 Put the live URL and name web service.
 In Default.aspx, put some controls.
 On source code behind, when you type in 'temp...' it automatically recognzie the webservice name TemperatureConvert. Good!

Note the code part how to use the webservice and its function. It's slightly different from what you can find from Google. I don't know. It worked that way in my case.

The program works fine.
 It looks exactly same as the MSDN website.

That's it for this blog.

Next step will be passing XML through web service:
http://msdn.microsoft.com/en-us/library/58a18dwa.aspx

Thursday, 8 August 2013

Phonegap drag and drop image

I thought it was easy.
I thought if I copy and paste of HTML5 Drag and Drop source from
http://www.w3schools.com/html/html5_draganddrop.asp into the index.html, it would work.

I was wrong.

Touch phone doesn't recognize mouse event.

After all the search, I found a working example.
http://popdevelop.com/2010/08/touching-the-web/

If you check the URL http://sewa.se/drag/ in the Android emulater browser, it works!!
View source-> copy and paste into your index.html.

Or download the index.html below.
https://docs.google.com/file/d/0B_V2TTxMUlvVQVJNMlNORGl1WGs/edit?usp=sharing

Then I did little bit more to drag and drop image one another.


You can get the updated index.html below.
https://docs.google.com/file/d/0B_V2TTxMUlvVWmx5Smp2N21vZlE/edit?usp=sharing 



Phonegap install in Windows 64bit (for Android app)

I followed the installation process in Phonegap.

There were a few folders I used:
  • C:\AndroidSDK (x) - zip download
  • C:\Development - program files, phonegap source code
  • C:\Android (x) - android source code
  • C:\Node

1, 1.5. I had to reinstall Android adt (it contains android sdk + eclipse) in C:\Development



2. After installing Node.js, I tested and saved the source code in C:\Node

3, 3.1. I don't use C:\Android any more. It just contains the test code I did for Android study.



3.5 C:\AndroidSDK Download - I just saved zip file here. adt zip file seems to have date stamp everyday?!



4. I had to change Path variable many times after installing different softwares. (Path contains %JAVA_HOME%\bin;)

5. The current Path (system variable) looks like this.

5.5 Note that I added JAVA_HOME, ANT_HOME to system variable as well.
The details are at the end of this posting.


6. I failed in adding android platform. I found later this is because my ADT was not set up properly for 64 bit.

7, 7.5. Make sure when you type 'android' in dos command, you can see some android SDK manager starting.


7.6, 7.7. You have to select android version as well. I mainly installed Adnroid 4.2.2.


8. Make sure you are in the right directory when you check installed platform. Otherwise you cannot see anything. In this case, you should have done the 'cordova platform ls' command in C:\Node\hello.


9. I had also problem in installing javac.exe. When I run eclipse.exe I had error.

10.1, 10.2, 10.3 So I had to install java again, but not jre, the jdk.



11. If java is not installed properly, you cannot add android platform.

12. Every time, you change system variable or install java, you have to restart PC to reflect the new path. Log off is not enough.

14, 14.1 I also had to install ANT after installing java.


15, 15.1. After doing all this installation, i could add android platform.


16. You need to emulate in android

17. You can import sample code into sdk if you don't want to see the default html file.

18, 18.1. You need to assign target device to emulate. (or AVD, Android Virtual Device)


19. Finally you can see emulate screen. And wait a bit more, you will see the index.html.

20. FYI, cordova 3.0 doesn't work 'create' function. You have to use 'emulate'.

21. Change index.html whatever you want.

22. You can see it in emulator.

How to deploy into your phone? That's our next task.

-------------

Path (system variable)
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files\Intel\DMIX;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\nodejs\;C:\Development\adt-bundle-windows-x86_64-20130729\sdk\platform-tools;C:\Development\adt-bundle-windows-x86_64-20130729\sdk\tools;%JAVA_HOME%\bin;%ANT_HOME%\bin;

Path (user variable)
C:\Users\Matthew.Oh\AppData\Roaming\npm;C:\Development\adt-bundle-windows-x86_64-20130729\sdk\tools

JAVA_HOME
C:\Program Files\Java\jdk1.7.0_25

ANT_HOME
C:\Development\apache-ant-1.9.2-bin\apache-ant-1.9.2

Wednesday, 20 March 2013

MVC

MVC - Model View Controller

Controller - main function place that controls everything
Model - Connected to database tables, objects
View - reads data from user, play with Model, and displays

Name conventions:
HomeController.cs controls Views/Home.
Function f1() { return View(); } in HomeController.cs returns view, Views/Home/f1.cshtml

Instead of mapping incoming URLs to files, they instead map URLs to methods on classes.

The url ~/first/second/third means {controller}/{action}/{parameters}. It means, FirstController.cs has a function second() with a parameter third, and if the function returns View(), it will show Views\First\Second.cshtml.

visual studio 2010 View folder has the following structure:

\Views\[ControllerName]\[ActionName]


Wednesday, 11 July 2012

FormView

FormView

<NameSpace>
System.Web.UI.WebControls

<Properties>
BackColor:
BackImageUrl:
ClientID:
Context: Gets the HttpContext
DataItem: Gets the data item bound to the FormView control
DataKey:
DataSource: gets or sets the object from which the formview retrieves its list of data items
Page: gets a reference to the Page instance
PagerStyle:

<Methods>
BuildProfileTree:
CreateTable: creates the containing table for the FormView control
DeleteItem: deletes the current record in the FormView
FindControl(String): searches the current naming container for a server control

<Events>
Init
ItemCreated()
ItemDeleted()