Step 1; in the aspx file, the div needs a unqiue id and set to runat="server":
<asp:Content ID="conent1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <div id="myDivId" runat="server" style="display: block;"> <p>foo bar</p> </div> </asp:Content>
Step 2; In the aspx.cs file, the ContentPlaceHolderId is retrieved first using the Page.Master.FindControl and then used to reference the div:
ContentPlaceHolder content = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1"); content.FindControl("myDivId").Visible = false;
Labels: code csharp
Had to look this up again so documenting for quick reference. It's rather simple to set a div style using the following steps:
Step 1; The div must have a unique id and be configured with runat="server":
<div id="myDivId" runat="server" class="head2">
Step 2; The code behind references the div as if it were any other Control on the page, using the Controls Style property to set a style attribute:
myDivId.Style["background-color"] = "#ffdd77";
Labels: code csharp
It's been widely discussed for some time that FAST had been under criminal investigation for financial “anomalies”, but now Reuters reports that Norway police charges Microsoft's Fast with fraud.
What affect will this have on FAST?
My guess is that it won’t have much of an impact. FAST, as "a Microsoft subsidy", has continued to do well technically in the market place (see Gartner Pegs Microsoft as Top Enterprise Search 'Leader') and legally Microsoft will weather any financial scandal of that occurred before the purchase of FAST.
Worse case, a further deemphasis on the FAST brand and more focus on Microsoft - but we knew that would be the case anyway ... .Still, it's a shame; no one likes it when an "All Star" is caught cheating.
Applications differ on their support for URL length because the specification fails to indicate any requirement for a minimum URL length (http://www.w3.org/Addressing/URL/url-spec.txt). MS Internet Explorer, for example, only support 2046 characters in it’s address box, a fraction of what other contemporary browsers will support. The Microsoft .NET Hyperlink component supports a much shorter URL, silently truncating the address, and Office applications and desktop shortcuts will fail to recognize links of even a moderate size.
The impact is that URLs with complex queries cannot be constructed or used reliably by many applications.
While there are design alternatives, such as using POST to send data to a server based session, any design choice that does not maintain the explicit page state in the URL will likely confuse users. That is, users expect that if they bookmark a page, they can come back to that page, even after a server side session has expired, and it will render identically. Other web paradigms include using the Web browsers back button to undo an action, something that .NET and AJAX applications frequently fail at since they don’t update the URL when updating the page state. For a demonstration of this, observe how even MS’s Live.com site maintains page state in the URL rather then use the .NET paradigm of post backs to the server.
So on the one hand, maintaining page state in the URL is desirable for usability, but on the other hand the inconsistency of support for URL lengths ensures the design will, in some case or another, fail. In some cases the failure may happen in such a way that the user is unaware of the failure –as when additional query parameters are truncated and the resulting page is not as expected. For example, a query that contains key=foo+AND+bar” and is truncated to key=abc would likely result in a silent failure.
To defend against these silent failures a Web application must be designed to test for a truncated URL. How this is done depends upon the application. For example, in one application a special character or keyword may be is placed at the end of an applications URL if it contains a query. In another, the query includes a parameter for URL length that is tested for. The key is that is that the pages URL cannot be assumed to be valid unless there is a test for validity.
Using the SyntaxHighlighter on non Blogger sites is pretty straightforward - for my notes on use, please see Using SyntaxHighlighter.
However, I and other have run into a bug when trying to deploy to a Blogger site, namely that <br/> would be inserted in the code when displayed to the page and, in my case, line returns would be ignored, resulting in all the code being writtent to one line.
I was able to find a solution on the Tips for software engineer site. In essence, add the following JavaScript to the page just before the closing body tag:
<script class='javascript'> //<![CDATA[ function FindTagsByName(container, name, Tag) { var elements = document.getElementsByTagName(Tag); for (var i = 0; i < elements.length; i++) { if (elements[i].getAttribute("name") == name) { container.push(elements[i]); } } } var elements = []; FindTagsByName(elements, "code", "pre"); FindTagsByName(elements, "code", "textarea"); for(var i=0; i < elements.length; i++) { if(elements[i].nodeName.toUpperCase() == "TEXTAREA") { var childNode = elements[i].childNodes[0]; var newNode = document.createTextNode(childNode.nodeValue.replace(/<br\s*\/?>/gi,'\n')); elements[i].replaceChild(newNode, childNode); } else if(elements[i].nodeName.toUpperCase() == "PRE") { brs = elements[i].getElementsByTagName("br"); for(var j = 0, brLength = brs.length; j < brLength; j++) { var newNode = document.createTextNode("\n"); elements[i].replaceChild(newNode, brs[0]); } } } //clipboard does not work well, no line breaks // dp.SyntaxHighlighter.ClipboardSwf = //"http://[YOUR HOST]/clipboard.swf"; dp.SyntaxHighlighter.HighlightAll("code"); //]]> </script>
Labels: blog, bug, code, JavaScript
Following provides details on adding the Google SyntaxHighlighter to a non Blogger site.
<link type="text/css" rel="stylesheet" href="/css/SyntaxHighlighter.css"></link> <script language="javascript" src="/js/shCore.js"></script> <script language="javascript" src="/js/shBrushCSharp.js"></script> <script language="javascript" src="/js/shBrushXml.js"></script> <script language="javascript"> dp.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf'; dp.SyntaxHighlighter.HighlightAll('code'); </script>
<pre name="code" class="c-sharp"> string [] s = {"a", "b", "c"}; for (int i = 0; i < s.Length; i++) { Console.WriteLine(s[i]); } </pre>
However, if using integrating with Blogger you may observe some problems - if so check out this article.
Labels: code, html, JavaScript
January 2007 | March 2007 | May 2007 | February 2008 | April 2008 | July 2008 | September 2008 | October 2008 | December 2008 | January 2009 | April 2009 | May 2009 | June 2009 | December 2009 | January 2010 |
Subscribe to Posts [Atom]