Wednesday, June 3, 2009

Set focus on control inside iFrame (jQuery)

//get the IFRAME element - note no hashes in the name, we're using browser functionality 
var iframeRef = document.getElementById("IFRAMEID"); 
//focus the IFRAME element 
$(iframeRef).focus(); 
//use JQuery to find the control in the IFRAME and set focus 
$(iframeRef).contents().find("#CONTROLID").focus();
 
Source

Saturday, May 23, 2009

My favorite Mozilla Ubiquity custom plug-ins

 

Imdb (with preview) - http://gist.github.com/59109

Mozilla Add-ons - http://projects.fligtar.com/ubiquity/add-on.php

Google

music is a command that use google hacks in order to find mp3 or ogg music.

video is a command that use google hacks in order to find video.

Note in Reader: Adds the current selection to your Google Reader Shared Items page and allows you to add a note to it

Google Image Search (preview, links, embedding) - http://www.jimmy2k.it/getimagescommand

jQuery

jquery: Searches the jQuery documentation.

Facebook

[script] with two commands:

  • 'facebook-status (your status)' - Updates your status, doesn't add "is"!
  • 'facebook-friend (your friend)' - Locate a friend. You have to type whole words, though (if searching for Amy Jones, you can't type Amy Jon; it must be one of: amy, jones, amy jones!)

Others

notepad - Opens Notepad on Windows

paint - Opens MS Paint on Windows

note - The purpose of this command is to quickly save the inputted text (can be selected text or your own text) to a file on your disk without having to launch a text editor.

 

All taken from here

Friday, March 27, 2009

pageLoad() – check if partial refresh

 

function pageLoad(sender, args) 
{
    if (args.get_isPartialLoad()) 
    {
        alert(”Ajax call”);
    } 
    else 
    {
        alert(”PostBack or initial load”);
    }
}

Friday, March 20, 2009

Code Formatting plug-in for Live Writer

This plug-in formats and highlights code and also does the following:

  • The ability to format the code 'live'
  • The ability to wrap lines
  • The ability to change the background color
  • The ability to just quickly paste what's in the clipboard as code
  • The ability to change the font, including the font name, size, weight, and style.
  • Dozens of languages, including PowerShell, MSIL, Pascal and XAML
  • NEW: The ability to use different formatting engines - in this release, ActiPro (Insert formatted code), and SyntaxHighlighter (Insert highlighted code)
  • NEW: The ability to output either formatted text (html) or images
  • NEW: Now works with the latest version of Windows Live Writer
  • NEW: The code editor now uses the superb ActiPro code editor.  ActiPro very kindly donated the license.

 

 

 

more info here

Monday, March 16, 2009

C#: Control over date formatting, replace ToShortDateString

 

I found that it is more flexible and readable for me to use the ToString formatting for dates

objDate.ToString("MM/dd/yyyy");

than to use this:

objDate.ToShortDateString()

Friday, February 6, 2009

How to manage ASP.NET validation from Javascript with jQuery

 

Just an example from the original article, but it is self explanatory

 
 
<asp:DropDownList ID="ddlMimeType" runat="server">
   <asp:ListItem Value="mp3">audio/mpeg</asp:ListItem>
   <asp:ListItem Value="wma">audio/wma</asp:ListItem>
   <asp:ListItem Value="other">Other</asp:ListItem>
</asp:DropDownList>
<asp:TextBox id="txbOtherMimetype" runat="server" />
<asp:RequiredFieldValidator id="valOtherMimetypeRequired" runat="server"
                   ControlToValidate="txbOtherMimetype" ForeColor="#990066"
                   ErrorMessage="You have to specify a custom mimetype." />
 

 

<script type="text/javascript">
$(document).ready(function()
{
  $("#<%= ddlMimeType.ClientID %>").change(function() 
  {
    toggleOtherMimeType(this);
  });
}
 
function toggleOtherMimeType(elem)
{
  if(elem!=undefined) 
  {
    if(elem.value=="other")
    {
      $("#<%= txbEnclosureOtherMimetype.ClientID %>").show();
      ValidatorEnable($("#<%= valEncOtherMimetypeRequired.ClientID %>")[0], true);
    }
    else
    {
      $("#<%= txbEnclosureOtherMimetype.ClientID %>").hide();
      ValidatorEnable($("#<%= valEncOtherMimetypeRequired.ClientID %>")[0], false);
    }
  }
}
</script>

 

Source

Tuesday, January 20, 2009

Converting Dates in SQL Server

 

image

SELECT 
   GETDATE() AS DefaultFormat,
   CONVERT(nvarchar(30), GETDATE(), 101) AS US,
   CONVERT(nvarchar(30), GETDATE(), 103) AS UK,
   CONVERT(nvarchar(30), GETDATE(), 111) AS Japan,
   CONVERT(nvarchar(30), GETDATE(), 104) AS German,
   CONVERT(nvarchar(30), GETDATE(), 112) AS ISO,
   CONVERT(nvarchar(30), GETDATE(), 109) AS Date_with_Milliseconds
 

image

Source

Friday, January 16, 2009

GridView Pager styling

Source

NY Mayor Michael Bloomberg talks about the conflict

Nettuts 960 CSS framework screencast



Source

JavaScript: Parent -> Frame function calls

For this example I have 2 html pages:

Page1.html and Page2.html

If Page2 is shown as iframe inside Page1 and has this function:

<script type="text/javascript">
        function showMessage(m) {
            document.getElementById("message").innerHTML = m;
        }
</script>

Than it can be called from Page1 like this:

<script type="text/javascript">
    window.onload = function() {
        window.frames[0].showMessage("Hello from Main Page in iFrame");
    };    
</script>

 

Source