Add CSS StyleSheet Link in ASP.NET page header at runtime

Friday, 24 April 2009 10:55 by myro

Is not really intuitive how can you add a reference to a css stylesheet at runtime in ASP.NET in the HTML head section: you need to call the page's ClientScript manager and register a Javascript script block defining your script code as a link tag. Remember that RegisterCssReference method will only work if you call it before the page's OnRender event method, so use it in OnLoad and OnPreRender page's events.

protected void RegisterCssReference(string CssLinkurl)
{
       if (!String.IsNullOrEmpty(CssLinkurl))
       {
           String sb = String.Empty;
           sb = String.Concat("<link rel=\"stylesheet\" href=\"", CssLinkurl,
                 "\" type=\"text/css\" media=\"screen\" />");
           Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "YOUR_KEY", sb , false);
       }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   .NET | Web
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Online free chart application from autodesk

Friday, 17 April 2009 17:22 by myro

Why should you pay for a chart program if you can geti it for free?
Autodesk published an impressive web application completely free to let you draw you own charts online.  Project Draw allows you to do everthing you need:

http://draw.labs.autodesk.com/ADDraw/draw.html

You don't need to have a product serial number to use all the features: just create an account and skip the last step where you are asked to provide the key:

 https://registeronce.autodesk.com/eidm/selfcare/beginSelfRegistration!input.action

Don't forget to register and press ctrl + d once you have visited the link Laughing

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Web
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Mootools live demos and sourcecodes

Wednesday, 1 April 2009 11:51 by myro

If you are considering to use Mootools javascript framework, and you need to see it in action, visit

 http://demos111.mootools.net/

to obtain immediatly cool effects and the relative sourcodes.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Developer Life | Web
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed

Open links into a new window based on the extensions

Thursday, 12 March 2009 16:48 by myro

Immagine a scenario where you need to handle how a browser should open different urls into your site. You need to open every link into a new browser's window except links to documents, to avoid opening a blank window.
Infact, using the attribute 'target' into an anchor: 

<a href=http://www.myrocode.com/document.doc target="_blank" >Open my document</a> 

will open first a new window, and then let you download the file.As you can see  this is not a good solution for this scenario.
Here you can find a simple Javascript that will resolve this kind of problem

 <script type="text/javascript">


function OpenIntoNewWindow(url)
{
    // this are the extensions that will be opened in the current windows
    var fileExtensions = new Array('rtf', 'log', 'txt', 'doc', 'pps', 'ppt', 'xls', 'xml',
                                        'docx', 'xsl', 'xlsx', 'ppt', 'pptx', 'mdb', 'accdb','pdf');
    var match = new Boolean(false);
    for (index in fileExtensions)
    {
        if (endsWith(url.toString().toLowerCase(), fileExtensions[index]))
        {
            // we've found a match!
            match = true;
            break;
        }
    }
    if (match == true)
    {
        window.location.href = url;
    } else window.open(url);
}


function endsWith(testString, endingString) {
    if (endingString.length > testString.length) return false;
    return testString.indexOf(endingString) == (testString.length - endingString.length);
}
</script>
<a style="cursor:pointer" onclick="OpenIntoNewWindow('http://www.myrocode.com/default.aspx');">
     my window html</a>
<br />
<a style="cursor:pointer" onclick="OpenIntoNewWindow('http://www.myrocode.com/SampleDocument.doc');">
     my window Doc</a>

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Web
Actions:   Bookmark and Share | Permalink | Comments (0) | Comment RSSRSS comment feed