Thursday, March 24, 2011

Read query string with Javascript

function requestQueryString(variable)
{
    var result = null;
    var queryString = window.location.search.substring(1);
    var variables = queryString.split("&");
    for (var i = 0; i < variables.length; i++)
    {
        var pair = variables[i].split("=");
        if (pair[0] == variable)
        {
            result = pair[1];
        }
    }
    return result;
}

Friday, July 16, 2010

Disable ASP.NET menu control items using JavaScript

function ToggleMenuItems(on)
{
    var state = "disabled";
    if (on)
    {
        state = "";
    }
    var element = null;
    //Note that "all" will only work for IE - replace with "childNodes" for other browsers
    var count = $get("").tBodies[0].rows[0].all.length;
    for (var i = 0; i < count; ++i)
    {
        element = $get("").tBodies[0].rows[0].all[i];
        if (element.nodeName == "A")
        {
            element.disabled = state;
        }
    }
}

Thank you to:  http://forums.asp.net/p/1545146/3775042.aspx

Add ToolTips to listbox items in ASP.NET (VB.NET)

Private Sub MyListBox_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles
    MyListBox.PreRender
    Dim i As Integer = 0
    Dim myToolTips As String() = MyHiddenField.Value.Split("|")
    For Each item As ListItem In MyListBox.Items
        item.Attributes.Add("title", myToolTips(i))
        i = i + 1
    Next
End Sub

Thank you to http://msmvps.com/blogs/deborahk/archive/2010/01/31/asp-net-listbox-tooltip.aspx

Test for IE using JavaScript

var IE = /*@cc_on!@*/false;
if (IE)
{
    //do IE stuff
}

Thank you to http://devoracles.com/the-best-method-to-check-for-internet-explorer-in-javascript.

Thursday, May 27, 2010

Include a reference to a cascading stylesheet

<link rel="stylesheet" type="text/css" href="stylesheet.css" />

Thursday, May 13, 2010

Fix WCF Service MaxItemsInObjectGraph Error

The error is:

"System.Runtime.Serialization.SerializationException: Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota."

The solution is:
  • Edit the Web.Config file
  • Add the following to the <system.serviceModel><behaviors> section:
      <endpointBehaviors>

          <behavior name="exampleBehavior">
            <dataContractSerializer maxItemsInObjectGraph="200000"/>
          </behavior>

      </endpointBehaviors>

      <serviceBehaviors>

        <behavior name="exampleBehavior">
          <dataContractSerializer maxItemsInObjectGraph="200000"/>
        </behavior>

      </serviceBehaviors>
  • Change the maxItemsInObjectGraph value to whatever the maximum number of items that you need to be serialized is (usually the maximum number of records that your service returns).

Reload the current page using JavaScript

window.location.reload();