Tuesday, November 16, 2010

Silverlight 4: Calling a Web Service in ServerSide

I was struggling of calling a webservice if the user logs off in Silverlight client.
For me to solve the problem I called the service in server side using javascript. Here's how to:


function sendDataAsXML_SOAP() {
var req_params = "", url = "", number = 0, type = "";
/* Configure Parameters */
url = "http://localhost/TempWS/MachineHistoryWS.asmx";
user = "129272802615082804";

req_params = "";
req_params = req_params + "";
req_params = req_params + "" + user + "
";
alert(req_params);
/* Send XML/SOAP Request To Web Service Using Browser's Javascript DOM */
try {
ajax_request = new XMLHttpRequest();
}
catch (trymicrosoft) {
try {
ajax_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
ajax_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
ajax_request = false;
}
}
}
ajax_request.open("POST", url, true);
ajax_request.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
ajax_request.onreadystatechange = receiveXML_SOAPData;
ajax_request.send(req_params);
}



For more of it click here

Wednesday, October 20, 2010

How to Debug a WebService

When running the solution, make sure it is Run as Administrator.

  1. Menu Debug > Attach to process

  2. Find process w3wp.exe

  3. Click attach

  4. Set breakpoint(s)


A sample problem of mine that I resolve using this can be found here


Sunday, October 10, 2010

How to increase quota in Isolated File Storage

IsolatedStorageFile Class represents an isolated storage area containing files and directories.

To increase its quota you can read this

Sunday, September 5, 2010

PDF Viewer in Silverlight 4.0

There are a lot of ways on viewing PDF for Silverlight.

Here's some

Monday, August 30, 2010

Executing a webservice on browser close Event

How to execute a webservice method on browser close event in silverlight? You cannot really do it in Application_Exit() method. You need to do it in server side not on client side.

To do it, here's the code:

function sendDataAsXML_SOAP() {
var req_params = "", url = "", number = 0, type = "";
/* Configure Parameters */
url = "http://localhost/TempWS/MachineHistoryWS.asmx";
user = "129272802615082804";

req_params = "";
req_params = req_params + "";
req_params = req_params + "" + user + "
";
alert(req_params);
/* Send XML/SOAP Request To Web Service Using Browser's Javascript DOM */
try {
ajax_request = new XMLHttpRequest();
}
catch (trymicrosoft) {
try {
ajax_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (othermicrosoft) {
try {
ajax_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (failed) {
ajax_request = false;
}
}
}
ajax_request.open("POST", url, true);
ajax_request.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
ajax_request.onreadystatechange = receiveXML_SOAPData;
ajax_request.send(req_params);
}

Wednesday, April 7, 2010

WPF Features NOT in Silverlight Beta 4.0 and other restrictions

1. Simple Inline XAML

2. Silverlight does not support dynamic resources
Only static resources

3. No XPath binding

4. Triggers
workaround
Expression.Samples.Interactivity
System.Windows.Interactivity

Download the example here

5. Silverlight compiled DLL's can only be reference to your Silvelight project.

6. DocumentViewer Control

7. Adorner

8. MultiBindings

9. Updatetrigger

10. Cannot read and write to your local disk
Example:
HtmlPage.Window.Navigate(new Uri("C:\\Users\\userName\\Downloads\\test.pdf"), "_blank");
HtmlPage.Window.Navigate(new Uri("C:\\Users\\userName\\AppData\\LocalLow\\Microsoft\\Silverlight\\is\\t1frcinf.y5b\\adbxgs00.suq\\1\\s\\i4j5zwj5lwo3dexs43ahtvmg2bjlsx11spczjmw5ud3c3dignoaaahea\\f\\MHVStore\\WhatsNewInSilverlight4.pdf"), "_blank");


*** You can access the absolutepath of your IsolatedStorage but it is not the best practice.

10. Refection

Tuesday, April 6, 2010

C# How to open a file

Syntax for opening a file is:

System.Diagnostics.Process.Start("FileNameHere");



However this is not permitted in Silverlight 4.0

Monday, February 15, 2010

Silverlight 4.0 and Visual Studio 2010 Released Candidate

Only Silverlight 3 projects are supported with the Visual Studio 2010 Release Candidate build – however Silverlight 4 projects are not yet supported.
If you are doing Silverlight 4.0 development, it is recommended to stay in Visual Studio 2010 Beta 2 build for now.

For more info you can check the links below:
Quick FAQ on Visual Studio 2010 RC …
VS2010 RC and SL4

About Me

My photo
simple and straight forward