I learned to love the webpack's "-w" option, which auto-recompiles the bundle(s) whenever source file is changed. Plus, it's really fast comparing to the full compile.
However, I ran into issue - when I moved my project from one computer to another, I found out that even though I can run webpack fine (it compiles all), it did NOT trigger the auto-recompile when I was modifying the source files.
After lots of experimentation, I found out that it was related to the folder name.
There's a bug reported already on that subject.
In short, you cannot have "(" or ")" anywhere in the path to your project.
So while this works fine:
c:\my projects\sample1\root
This stops watch from working:
c:\(my projects)\sample1\root
Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts
Thursday, May 26, 2016
Tuesday, March 15, 2011
Calling OperationContract in SVC using JavaScript
I was attempting to use WebMethod in a masterpage. Since .Net doesn't support static inheritance, I was out-of-luck. The obvious alternative was to use web-service to do the job. Since I was using .net 4.0, I was hoping to utilize the SVC and not ASMX.
Here's how you can make it work:
1) add "myservice1.svc" using the "Add New Item" -> "AJAX-enabled WCF-Service" menu. Notice that it adds section to your web.config and also "myservice1.cs" into your App_Code.
2) create your method in the "App_Code/myservice1.cs" (sample method below). Warning! If you're using Web Site project as me, don't put anything in the ServiceContract's Namespace!
[OperationContract]
public void SampleMethod1(int param1)
{
// your code here
}
3) Next step is to register this service in your ScriptManager (in my case, I have it on my master page):
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/myservice1.svc" />
</Services>
</asp:ScriptManager>
4) Finally JavaScript that will call the method:
myservice1.SampleMethod1(2);
It's really that simple - the ScriptManager makes the "myservice1" available and you just call the methods. Again, please note that there's no namespace.
Thursday, May 01, 2008
Read and parse Excel data from clipboard using Javascript
IE7 prevent clipboard from being read - you can enable it in the title-bar (blocked content). For Firefox read this info.
Following sample reads data from clipboard and tries to parse them and format back to table.
// prepare result
var resE = document.getElementById("result");
var res = "";
resE.innerHTML = "";
// read clipboard
var s = window.clipboardData.getData("Text");
// parse clipboard data
var lines = s.split(String.fromCharCode(13,10));
if (s.indexOf(String.fromCharCode(13,10)) == -1 || s.indexOf(String.fromCharCode(9)) == -1)
{
res = "(invalid data)";
}
else
{
var cols = lines[0].split(String.fromCharCode(9));
res = "Table size: " + lines.length + "x" + cols.length + "
";
res += "";
";
}
// output result
resE.innerHTML = res;
Following sample reads data from clipboard and tries to parse them and format back to table.
// prepare result
var resE = document.getElementById("result");
var res = "";
resE.innerHTML = "";
// read clipboard
var s = window.clipboardData.getData("Text");
// parse clipboard data
var lines = s.split(String.fromCharCode(13,10));
if (s.indexOf(String.fromCharCode(13,10)) == -1 || s.indexOf(String.fromCharCode(9)) == -1)
{
res = "(invalid data)";
}
else
{
var cols = lines[0].split(String.fromCharCode(9));
res = "Table size: " + lines.length + "x" + cols.length + "
";
res += "
| " + (cols[j] == "" ? "~" : cols[j]); } res += " |
}
// output result
resE.innerHTML = res;
Subscribe to:
Posts (Atom)