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