Tuesday, May 29, 2012

CSS: Rewriting element declarations

CSS: Rewriting element declarations

There is a common link declaration
a {
color: #993300;
text-decoration: none;
cursor: hand;
}
a:hover {
color:#993300;
text-decoration:underline;
}
a:visited {
color:#4c7095;
}
For some links I have to rewrite link declarations. For example, I have to change colors, font-weight, and  text-decoration for some link. It's not obvious task, and I spent 30-40 minutes on Internet looking for some ideas. One of the idea was to use on MouseOver and OnMouseOut events which does not work if link is visited.  I continued my search and found some excellent idea.  The idea was posted on stackoverflow.com by  the owner of the site rexmorgan.net Here is his suggestion:
"Inline styles only have rules; the selector is implicit to be the current element.
The selector is an expressive language that describes a set of criteria to match elements in an XML-like document.
However, you can get close, because a style set can technically go most anywhere:
<style>
#uniqueid:hover {do:something;}
</style>
<a id="uniqueid">hello</a>"

So, following his advice, I added unique id to my link:
<a href="../../../test.aspx" class="topLink" accesskey="0" id="js2" title="Go to Test page">Help</a>

And added some code in CSS:

.topLink 
{
    color: #ffffff;
    font-weight: bold;
    text-decoration: underline;
}

#js2:hover
{
    color: #ffffff;
    font-weight: bold;
    text-decoration: underline;
}


#js2:visited
{
    color: #ffffff;
    font-weight: bold;
    text-decoration: underline;
}


Now my link looks and behaves differently than all links on my website.

Tuesday, May 22, 2012

Javascript: single quote inside the string.

Working on my project, I had to construct a string inside with single quotes. It was a small challenge for me. I did not know how to keep single quotes inside the string. Researching the Internet I found the best way to keep single quotes inside the string. Here's an example:

var temp2 = 'onclick = "window.location=\'test.aspx\'; return false;"';

Back-slash in front of the quote keeps the quote inside of the string.  Browser will resolve this statements as
onclick = "window.location='test.aspx'; return false;" 

Wednesday, May 9, 2012

Problems with file editing in SharePoint

 Trying to check out and edit Word-document, my coworker got the error (see picture above). Of course, he asked me for help. It's not first time my coworkers receive the same message, and I decided to research the problem. Actually I found some good tips on Internet. One of them is on http://sharepointknowledgebase.blogspot.com . I think, we have a similar situation. The blogger offered some explanations, and I think, they are quite realistic. Here they are:

"The document could not be opened for editing. A Windows SharePoint Services compatible application could not be found to edit the document.
One of the user from my project reported that he was not able to edit as well as check out the office documents. When i tried to followed the same procedure (i.e. Edit,check-in, check-out) and strange thing was me also got the same error message. When i started my troubleshooting, I found out user created document library with multiple nested folders.

When we go to third or fourth level of the folder and try to edit any file with office application, we are getting an error – The document could not be opened for editing. A Windows SharePoint Services compatible application could not be found to edit the document. However if we try to edit the document uploaded on the root of the document library, we can edit it properly.

I tried reproduced the issue 2-3 times and found out one common thing and that is: You can not edit the office document once the URL path reaches characters limit 340. You can edit the documents only till URL path length is upto 339 characters. You can open the documents, you can upload documents but you can't edit them by right click on document and click on "edit in Microsoft Word". Even this behavior is same with non-office documents also like text documents.

Workaround:
-The only workaround possible is - open the file directly from the folder, modify and save it as a new file. Every time you need to save it as a new file. It wont allow to save in the existing file. Or, Move the file one level up and you will be able to do all the operations like edit,check-in and check-out too."