Wednesday, 28 May 2014

Rename column name in SharePoint online List View

To rename the Column name in SharePoint Online List view, use the following jQuery


<script type="text/javascript"
    src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js">
</script>
<script type="text/javascript">
    $(document).ready(function () {      
        renameColumnName('Title');
    });
    function renameColumnName(c) {
        $(".ms-formlabel h3 nobr").filter(function () {
            var thisText = $.trim($(this).clone().children().remove().end().text());
            return thisText.indexOf(c) === 0 && thisText.length === c.length;
        }).html('Title1');
    }
</script>

In the rename Column name function first we need to find out the title column and then using HTML function of jQuery we are replacing it.

Thursday, 12 September 2013

JavaScript parseInt function fails in IE8 for string "08" and "09"

We have used the java script function parseInt to parse the strings, however on the 9 th sept it started failing, I debugged the script and observed the following things :

var dt = parseInt("09");  // gives result as 0
var dt = parseInt("08");   // gives result as 0
var dt = parseInt("07");  // gives result as 7

solution is specify base 10

var dt = parseInt("09", 10);  // gives result as 9
var dt = parseInt("08", 10);   // gives result as 8
var dt = parseInt("07", 10 );  // gives result as 7

Reason : Both parseInt('08') and parseInt('09') return zero because the function tries to determine the correct base for the numerical system used. In Javascript numbers starting with zero are considered octal and there's no 08 or 09 in octal, hence the problem.

Monday, 17 December 2012

Getting the value of XElement containing xlink and colon


Recently I faced one problem while reading the value of attribute for the XElement, I have XML in following format :


<document>
<figure xmlns:xlink="http://www.w3.org/1999/xlink" id="F1" xlink:href="image#F1.1" class="figure">
  <label>Fig. 1.</label>
  <caption> XYZ</caption>
</figure>
</document>


I have written following code to get the value of the href attribute of figure.


XDocument _xDocument = XDocument.Load(XXXXX);
// XXXXX - specify the path here

List<XElement> imageElements = _xDocument.Descendants("Figure").ToList(); 

foreach (XElement imageElement in imageElements)
{
    if (imageElement.Attribute("xlink:" + "href") != null)
     {
        string href = imageElement.Attribute("xlink:" + "href").Value;
     }
}


But I end up with the following exception :

The ':' character, hexadecimal value 0x3A, cannot be included in a name.


   at System.Xml.ValidateNames.ThrowInvalidName(String s, Int32 offsetStartChar, Int32 offsetBadChar)
   at System.Xml.ValidateNames.ParseNCNameInternal(String s, Boolean throwOnError)
   at System.Xml.XmlConvert.VerifyNCName(String name)
   at System.Xml.Linq.XName..ctor(XNamespace ns, String localName)
   at System.Xml.Linq.XNamespace.GetName(String localName, Int32 index, Int32 count)
   at System.Xml.Linq.XNamespace.GetName(String localName)
   at System.Xml.Linq.XName.Get(String expandedName)
   at System.Xml.Linq.XName.op_Implicit(String expandedName)

The solution for this is to use XNamespace as below:


XNamespace xlink = "http://www.w3.org/1999/xlink";

if (imageElement.Attribute(xlink  + "href") != null)
{
  string href = imageElement.Attribute(xlink + "href").Value;
}



Issue resolved yipee :)


Tuesday, 11 December 2012

Improve the SharePoint web application performance


Following are few quick tips for improving your SharePoint/ASP.Net web application performance :

1. Use minified or compressed version of the JavaScript files

While referring any third party JavaScript files, try to use their release version for example if we are planning to use the jQuery in your application you should refer minified and Gzipped version (32KB)

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>

instead of development version (252 KB)

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>

You can also minify and compress your js files using Visual studio extension available at

http://visualstudiogallery.msdn.microsoft.com/5469b7e2-90d7-4f54-b299-ae47e26323e6

You can install it in visual studio and at the time of development it self it get compressed. So you can refer the compressed version on your pages.

2. Using Script manager to composite the JavaScript files 

If you are using ASP.NET AJAX in your application, you can create a composite script automatically by using the ScriptManager control. To combine scripts, add the CompositeScript element and list the script references in the order that you want them included in the composite script. 


   <asp:ScriptManager ID="ScriptManager1" runat="server">
    <CompositeScript>
     <Scripts>
      <asp:ScriptReference Path="~/Scripts/Script1.js" />
      <asp:ScriptReference Path="~/Scripts/Script2.js" />
      <asp:ScriptReference Path="~/Scripts/Script3.js" />
     </Scripts>
     </CompositeScript>
  </asp:ScriptManager>



You can find more details about it at -
http://msdn.microsoft.com/en-us/library/cc488552%28v=vs.90%29.aspx



 


Migration issues for SAP.Connector.dll from Win 2003 to Win 2019 server

Recently I got task of migration of asmx web services from windows 2003 to windows 2019 server. These web services fetch data from SAP us...