sqlcmd -S <server>\<instance> -d <database> -i <sqlFile>.sql
Monday, September 30, 2013
Thursday, September 26, 2013
Simplifying calls to WebMethods with PageMethods AJAX
AJAX calls to WebMethods in ASP.net pages can be easier implemented (the javascript part) by using the PageMethod feature in Microsoft ASP.NET AJAX framework instead of jQuery.
The code I used to write (jQuery):
Just remember to activate PageMethods in your ScriptManager:
.ASPX
.ASPX.CS
The code I used to write (jQuery):
$(document).ready(function () {And this is the code I write now using PageMethods:
$("#Button1").click(function () {
$.ajax({
type: "POST",
url: "index.aspx/diHola",
data: "{'nombre': '" + $('#<%= TextBox1.ClientID %>').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: callbackFunction
});
});
function callbackFunction(response) {
alert(response.d);
}
});
function pageLoad(){
$("#Button1").click(function () {
PageMethods.diHola($get("<%= TextBox1.ClientID %>").value, callbackFunction);
return false;
});
}
function callbackFunction(response){
alert(response);
}
Just remember to activate PageMethods in your ScriptManager:
.ASPX
Tu nombre:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input type="button" data-role="none" ID="Button1" value="Enviar" />
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> </asp:ScriptManager>
<script type="text/javascript">
function pageLoad(){
$("#Button1").click(function () {
PageMethods.diHola($get("<%= TextBox1.ClientID %>").value, callbackFunction);
return false;
});
}
function callbackFunction(response){
alert(response);
}
</script>
.ASPX.CS
[WebMethod]
public static string diHola(string nombre)
{
return "Hola " + nombre;
}
Wednesday, September 25, 2013
Java: diagram for choosing a Collection type
Sometimes in Java I don't know which type of Collection should I use.
Furthermore, I can't remember all of them and what are they for, so I use a diagram I found some time ago. It really came in handy while I was working for GMV.
(I can't find the one in English!)
Diagram source: http://chatejus.blogspot.com.es/2011/04/decidir-que-tipo-de-coleccion-usar-java.html
Furthermore, I can't remember all of them and what are they for, so I use a diagram I found some time ago. It really came in handy while I was working for GMV.
(I can't find the one in English!)
Diagram source: http://chatejus.blogspot.com.es/2011/04/decidir-que-tipo-de-coleccion-usar-java.html
Thursday, September 19, 2013
jQuery FullCalendar and ASP.Net: Problems with AJAX requests and responses
The "Fullcalendar" plugin for jQuery sends two parameters ("start" and "end") as form parameters via POST requests, which are not well processed by ASP.net WebServices (version >=3.5), which are expecting a well-formed JSON.
The result of the asp.net webmethod is a JSON object nested in the property "d" of another JSON object. This sintax is not understandable by Fullcalendar.
To solve these problems just edit fullcalendar.js changing _fetchEventSource function:
Note: JSON.stringify() is a function from the json2.js library.
The result of the asp.net webmethod is a JSON object nested in the property "d" of another JSON object. This sintax is not understandable by Fullcalendar.
To solve these problems just edit fullcalendar.js changing _fetchEventSource function:
[...]
$.ajax($.extend({}, ajaxDefaults, source, {
data: JSON.stringify(data), // -- Line changed
success: function(events) {
//events = events || []; -- Line commented
events = events.d; // -- Line added
[...]
Note: JSON.stringify() is a function from the json2.js library.
Tuesday, August 27, 2013
How to use VMware and HyperV alternately in Windows Server 2012
VMware workstation can not be installed nor executed in Windows Server if HyperV is running, so to do it HyperV should be deactivated at boot time.
By following these steps you'll change the boot menu to offer 2 options: boot with HyperV support and boot withOUT HyperV support (so you can run VMware).
(The reason why I want to run VMware sometimes is to virtualize USB devices without third party solutions like USB over Network).
Execute in a command line as Administrator:
By following these steps you'll change the boot menu to offer 2 options: boot with HyperV support and boot withOUT HyperV support (so you can run VMware).
(The reason why I want to run VMware sometimes is to virtualize USB devices without third party solutions like USB over Network).
Execute in a command line as Administrator:
- BCDEDIT /COPY {DEFAULT} /D "No HyperV support"It copies the current boot entry into a new one called "No HyperV support". (Remember to retype the double-quotes if you copy and paste the command)
- BCDEDIT /SET {COPYHERETHEIDTHEPREVIOUSCOMMANDRETURNED} HYPERVISORLAUNCHTYPE OFFIt deactivates the HyperV support for the boot entry we just created.
- BCDEDIT /DEFAULT {COPYHERETHEIDTHEFIRSTCOMMANDRETURNED}It sets the new boot entry as default.
- BCDEDIT /ENUM /VChecks if the new entry is correctly set up.
Friday, August 23, 2013
Installing VMware 9 in Debian Jessie with 3.10 kernel
Today I reinstalled Linux and some software in my HP Pavillion laptop. I installed Debian Linux Testing (currently called Jessie) and upgraded the kernel to 3.10-2-amd64.
After that, I successfully installed VMware 9.0.2, but when I tried to open it for the first time...the compilation of kernel modules failed.
If you have problems trying to enter your serial number through the UI, give the command line a try:
After that, I successfully installed VMware 9.0.2, but when I tried to open it for the first time...the compilation of kernel modules failed.
I did some googling and found that "The call
create_proc_entry()
has been dropped from 3.10 in favor of proc_create()
. This requires patching of the vmblock
and vmnet
modules that use them."
So, to solved the compilation problem you just have to patch some files following the instructions listed in Archlinux Wiki: https://wiki.archlinux.org/index.php/VMware#3.10_kernels
Patches for older kernels are also provided in that site.
3.10 kernelsThe call(Remember: commands preceded by "#" should be executed as root)create_proc_entry()
has been dropped from 3.10 in favor ofproc_create()
. This requires patching of thevmblock
andvmnet
modules that use them.
The patches (including the optional fuse patch) can be found here and here:
$ cd /tmp
$ curl -O http://pkgbuild.com/git/aur-mirror.git/plain/vmware-patch/vmblock-9.0.2-5.0.2-3.10.patch$ curl -O http://pkgbuild.com/git/aur-mirror.git/plain/vmware-patch/vmnet-9.0.2-5.0.2-3.10.patch$ cd /usr/lib/vmware/modules/source
# tar -xvf vmblock.tar
# tar -xvf vmnet.tar
# patch -p0 -i /tmp/vmblock-9.0.2-5.0.2-3.10.patch
# patch -p0 -i /tmp/vmnet-9.0.2-5.0.2-3.10.patch
# tar -cf vmblock.tar vmblock-only
# tar -cf vmnet.tar vmnet-only
# rm -r vmblock-only
# rm -r vmnet-only
# vmware-modconfig --console --install-all
If you have problems trying to enter your serial number through the UI, give the command line a try:
/usr/lib/vmware/bin/vmware-vmx --new-sn XXXXX-XXXXX-XXXX-XXX-XXXXX
Subscribe to:
Posts (Atom)