Obtener las coordenadas de un elemento html

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

/* 
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the 
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition. 
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the 
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the 
   anchor tag correctly. Do not do <A></A> with no space.
*/ 

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
function getAnchorPosition(anchorname) {
 // This function will return an Object with x and y properties
 var useWindow=false;
 var coordinates=new Object();
 var x=0,y=0;
 // Browser capability sniffing
 var use_gebi=false, use_css=false, use_layers=false;
 if (document.getElementById) { use_gebi=true; }
 else if (document.all) { use_css=true; }
 else if (document.layers) { use_layers=true; }
 // Logic to find position
  if (use_gebi && document.all) {
  x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  }
 else if (use_gebi) {
  var o=document.getElementById(anchorname);
  x=AnchorPosition_getPageOffsetLeft(o);
  y=AnchorPosition_getPageOffsetTop(o);
  }
  else if (use_css) {
  x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  }
 else if (use_layers) {
  var found=0;
  for (var i=0; i<document.anchors.length; i++) {
   if (document.anchors[i].name==anchorname) { found=1; break; }
   }
  if (found==0) {
   coordinates.x=0; coordinates.y=0; return coordinates;
   }
  x=document.anchors[i].x;
  y=document.anchors[i].y;
  }
 else {
  coordinates.x=0; coordinates.y=0; return coordinates;
  }
 coordinates.x=x;
 coordinates.y=y;
 return coordinates;
 }

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
 var coordinates=getAnchorPosition(anchorname);
 var x=0;
 var y=0;
 if (document.getElementById) {
  if (isNaN(window.screenX)) {
   x=coordinates.x-document.body.scrollLeft+window.screenLeft;
   y=coordinates.y-document.body.scrollTop+window.screenTop;
   }
  else {
   x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
   y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
   }
  }
 else if (document.all) {
  x=coordinates.x-document.body.scrollLeft+window.screenLeft;
  y=coordinates.y-document.body.scrollTop+window.screenTop;
  }
 else if (document.layers) {
  x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
  y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
  }
 coordinates.x=x;
 coordinates.y=y;
 return coordinates;
 }

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
 var ol=el.offsetLeft;
 while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
 return ol;
 }
function AnchorPosition_getWindowOffsetLeft (el) {
 return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
 } 
function AnchorPosition_getPageOffsetTop (el) {
 var ot=el.offsetTop;
 while((el=el.offsetParent) != null) { ot += el.offsetTop; }
 return ot;
 }
function AnchorPosition_getWindowOffsetTop (el) {
 return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
 }

Fuente: http://blog.crowe.co.nz/attachments/AnchorPosition.js

Acceder a un campo html por el nombre con jQuery

$('[name=NOMBRE-DEL-CAMPO]').val();    //para obtener el valor de un combo, por ej
   $('[name=NOMBRE-DEL-CAMPO]').text();   //para obtener el texto

Alternativa para poder pasar campos readonly en el submit con jQuery

Los campos de formulario readonly no se envian en el submit del form.
El siguiente código permite duplicar todos los campos select que existan en el formulario, creando un nuevo campo con el mismo contenido, y readonly. El script oculta el campo original.
De esta manera, visualmente aparece el readonly, pero en el formulario, viajara solo el oculto.

function soloLectura(selectElementId)
{
 var selectElement = document.getElementById(selectElementId);
 if (selectElement){  
  var parent = selectElement.parentElement;
  var textValue = selectElement.options[selectElement.options.selectedIndex].innerText;
  
  if (!parent){
   parent=selectElement.parentNode;
   textValue = selectElement.options[selectElement.options.selectedIndex].text;
  }

  ip = document.createElement("select");
  ip.name = "prueba";
  ip.options[0] = new Option(textValue, "aaaaaaa");
  
  ip.disabled = true;
  
  parent.replaceChild(ip, selectElement);

  selectElement.style.background="#ff0000";
  parent.appendChild(selectElement);

  selectElement.style.visibility = "hidden";
 }
}


$(document).ready(function() {
 v = $("select");

 v.each(function() {  
  elem = $(this);
  if (elem.attr("onfocus"))
  {
   if (elem.attr("onfocus").toString().indexOf("SFReadOnly") >= 0)
   {
    soloLectura(elem.attr("name"));
   }
  }
 });

 
});

Agregar un registro a una lista de sharepoint con web services

wsList.Lists list = new wsList.Lists();

list.Credentials = new NetworkCredential("usuario", "password", "dominio");

XmlNode listXml = list.GetList("Cursos");
string s = "<Batch OnError='Continue'>" +
           "<Method ID='1' Cmd='New'>" +
           "<Field Name='id_curso'>1234</Field>" +
           "<Field Name='nombre_curso'>prueba1</Field>" +
           "</Method>" +
           "</Batch>";
XmlDocument xmlDoc = new XmlDocument();


xmlDoc.InnerXml = s; 
  
XmlNode result = list.UpdateListItems("Cursos", xmlDoc); 

 
Notas: se pueden incluir tantos "Method" como sean necesarios. Cada ID debe ser único (en el ej. hay una sola sentencia, con id 1 si se agregan mas definirlas con id 2, 3, etc)
 
en el xml llamado result, queda el resultado de la ejecución batch (si se produjo algún error aparece allí)

Se pueden utilizar las credenciales del usuario logueado mediante esta sentencia:

list.Credentials = System.Net.CredentialCache.DefaultCredentials; 

CSS friendly adapters

Link para descargar - CSS friendly adapters


http://download.microsoft.com/download/b/a/3/ba3aee5e-2e28-4056-9e71-036b2e7f58af/ASPNETCssFriendlyAdapters.vsi

Walkthrough:

http://www.asp.net/CSSAdapters/WalkThru/WalkThrough.aspx#DownloadAndInstall

Como usarlos en SHAREPOINT
http://vspug.com/mossman/2007/03/08/css-friendly-control-adapters-in-sharepoint-2007-a-walk-through/

http://blogs.tamtam.nl/frank/PermaLink,guid,aad39854-4f7d-4666-8a0a-0fc02f3cd01b.aspx

Consulta con conexión DSNLess a MySql desde C#

using System.Data.Odbc;


string odbcconnstr = "Driver={MySQL ODBC 3.51 Driver};Server=servidor;Database=base;User=usuario;Password=password;Port=puerto;Option=4";

OdbcConnection conn;

conn = new OdbcConnection(odbcconnstr);
conn.Open();
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = conn;
cmd.CommandText = "select * from tabla";
OdbcDataReader dr = cmd.ExecuteReader();

while (dr.Read())
{
   // codigo                   
}

conn.Close();

Agregar texto a una celda



using Microsoft.Office.Interop.Excel;
Range rango = Globals.ThisAddIn.Application.Cells;
rango[1, 1] = "Datos en celda!!";

Conexión DSNLess a MySql utilizando MySql ODBC 3.51

Dim conn
Set conn = CreateObject("ADODB.Connection")
conn.Open "Driver={MySQL ODBC 3.51 Driver};Server=servidor;Database=base;User=usuario;Password=password;Port=puerto;Option=4;"

msgbox "ok!"

Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System

Para visual studio 2005, instalar esto:

http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86CAB3-6FD6-4955-B979-E1676DB6B3CB&displaylang=en

Consultas recursivas con CAML


<Query>
   <Where>
      <Eq>
         <FieldRef Name='nombre_campo' />
         <Value Type='Number'>1234</Value>
      </Eq>
   </Where>
<QueryOptions>
   <ViewAttributes Scope = 'Recursive'/>
</QueryOptions>
</Query>

Crear un asp menu por código

        Menu m = new Menu();

        XmlDataSource x = new XmlDataSource();

        x.DataBind();      
        x.EnableCaching = false;

        m.MaximumDynamicDisplayLevels = 4;
        m.StaticDisplayLevels = 10;

        m.DynamicHorizontalOffset = 1;
        m.DynamicVerticalOffset=1;


        string s = "" + "";

        x.Data = s;



        m.DataSource = x;




        m.DataBind();

       // Controls.Add(m);
       // m.DataBind();

       
        form1.Controls.Add(m);
        //Panel1.DataBind();

Ampliar el tamaño del disco duro en VirtualBox





1. Crear un segundo disco para la máquina que se desee ampliar, con la capacidad que se quiera (ej, si tengo un disco de 10gb, agrego otro de 30gb y lo establezco como primary slave)


2. Mapear el CD-ROM de la máquina, con el ISO de clonezilla (se puede bajar el iso desde: www.clonezilla.org)


3. Reiniciar la máquina, seguir las instrucciones de clonezilla (clonar disco a disco)


4. Cuando finalice la operación de clonezilla, cambiar el disco primary slave para que quede como primary master, y el otro dejarlo como primary slave (este último se puede borrar luego de verificar que todo quedó ok)


5. Iniciar la máquina. Ir al administrador de discos y extender la partición del c: para que ocupe todo el espacio disponible.


6. Listo, se puede borrar el disco primary slave.





Hay una guía mas extensa en http://www.my-guides.net/en/content/view/122/26/
pero el método anterior funciona OK.