iNerd Blog

Relationship

Posted in Uncategorized by Ari on 25 August 2010

A little out of place but, i thought this is a good reading material

MARRIAGE

When I got home that night as my wife served dinner, I held her hand and said, I’ve got something to tell you. She sat down and ate quietly. Again I observed the hurt in her eyes.

Suddenly I didn’t know how to open my mouth. But I had to let her know what I was thinking. I want a divorce. I raised the topic calmly.

She didn’t seem to be annoyed by my words, instead she asked me softly, why?

I avoided her question. This made her angry. She threw away the chopsticks and shouted at me, you are not a man! That night, we didn’t talk to each other. She was weeping. I knew she wanted to find out what had happened to our marriage. But I could hardly give her a satisfactory answer; she had lost my heart to Jane. I didn’t love her anymore. I just pitied her!

With a deep sense of guilt, I drafted a divorce agreement which stated that she could own our house, our car, and 30% stake of my company.

She glanced at it and then tore it into pieces. The woman who had spent ten years of her life with me had become a stranger. I felt sorry for her wasted time, resources and energy but I could not take back what I had said for I loved Jane so dearly. Finally she cried loudly in front of me, which was what I had expected to see. To me her cry was actually a kind of release. The idea of divorce which had obsessed me for several weeks seemed to be firmer and clearer now.

The next day, I came back home very late and found her writing something at the table. I didn’t have supper but went straight to sleep and fell asleep very fast because I was tired after an eventful day with Jane.

When I woke up, she was still there at the table writing. I just did not care so I turned over and was asleep again.

In the morning she presented her divorce conditions: she didn’t want anything from me, but needed a month’s notice before the divorce. She requested that in that one month we both struggle to live as normal a life as possible. Her reasons were simple: our son had his exams in a month’s time and she didn’t want to disrupt him with our broken marriage.

This was agreeable to me. But she had something more, she asked me to recall how I had carried her into out bridal room on our wedding day.

She requested that every day for the month’s duration I carry her out of our bedroom to the front door ever morning. I thought she was going crazy. Just to make our last days together bearable I accepted her odd request.

I told Jane about my wife’s divorce conditions. . She laughed loudly and thought it was absurd. No matter what tricks she applies, she has to face the divorce, she said scornfully.

My wife and I hadn’t had any body contact since my divorce intention was explicitly expressed. So when I carried her out on the first day, we both appeared clumsy. Our son clapped behind us, daddy is holding mommy in his arms. His words brought me a sense of pain. From the bedroom to the sitting room, then to the door, I walked over ten meters with her in my arms. She closed her eyes and said softly; don’t tell our son about the divorce. I nodded, feeling somewhat upset. I put her down outside
the door. She went to wait for the bus to work. I drove alone to the office.

On the second day, both of us acted much more easily. She leaned on my chest. I could smell the fragrance of her blouse. I realized that I hadn’t looked at this woman carefully for a long time. I realized she was not young any more. There were fine wrinkles on her face, her hair was graying! Our marriage had taken its toll on her. For a minute I wondered what I had done to her.

On the fourth day, when I lifted her up, I felt a sense of intimacy returning. This was the woman who had given ten years of her life to me.

On the fifth and sixth day, I realized that our sense of intimacy was growing again. I didn’t tell Jane about this. It became easier to carry her as the month slipped by. Perhaps the everyday workout made me stronger.

She was choosing what to wear one morning. She tried on quite a few dresses but could not find a suitable one. Then she sighed, all my dresses have grown bigger. I suddenly realized that she had grown so thin, that was the reason why I could carry her more easily.

Suddenly it hit me… she had buried so much pain and bitterness in her heart. Subconsciously I reached out and touched her head.

Our son came in at the moment and said, Dad, it’s time to carry mom out. To him, seeing his father carrying his mother out had become an essential part of his life. My wife gestured to our son to come closer and hugged him tightly. I turned my face away because I was afraid I might change my mind at this last minute. I then held her in my arms, walking from the bedroom, through the sitting room, to the hallway. Her hand surrounded my neck softly and naturally. I held her body tightly; it was just like our wedding day.

But her much lighter weight made me sad. On the last day, when I held her in my arms I could hardly move a step. Our son had gone to school. I held her tightly and said, I hadn’t noticed that our life lacked intimacy.

I drove to office…. jumped out of the car swiftly without locking the door. I was afraid any delay would make me change my mind…I walked upstairs. Jane opened the door and I said to her, Sorry, Jane, I do not want the divorce anymore.

She looked at me, astonished, and then touched my forehead. Do you have a fever? She said. I moved her hand off my head. Sorry, Jane, I said, I won’t divorce. My marriage life was boring probably because she and I didn’t value the details of our lives, not because we didn’t love each other anymore. Now I realize that since I carried her into my home on our wedding day I am supposed to hold her until death do us apart.

Jane seemed to suddenly wake up. She gave me a loud slap and then slammed the door and burst into tears. I walked downstairs and drove away.

At the floral shop on the way, I ordered a bouquet of flowers for my wife. The salesgirl asked me what to write on the card. I smiled and wrote, I’ll carry you out every morning until death do us apart.

That evening I arrived home, flowers in my hands, a smile on my face, I run up stairs, only to find my wife in the bed – dead.
My wife had been fighting CANCER for months and I was so busy with Jane to even notice. She knew that she would die soon and she wanted to save me from the whatever negative reaction from our son, in case we push thru with the divorce.– At least, in the eyes of our son— I’m a loving husband….

The small details of your lives are what really matter in a relationship. It is not the mansion, the car, property, the money in the bank. These create an environment conducive for happiness but cannot give happiness in themselves. So find time to be your spouse’s friend and do those little things for each other that build intimacy. Do have a real happy marriage!

If you don’t share this, nothing will happen to you.

If you do, you just might save a marriage.
Many of life’s failures are people who did not realize how close they were to success when they gave up.

A CHRIST-CENTERED MARRIAGE IS A MARRIAGE THAT IS SURE TO LAST A LIFETIME.

So then, they are no longer two but one flesh. Therefore what God has joined together, let not man separate. Matthew 19:6.

By Stephanie Halmilton

Tagged with:

Model Binding To A List ASP.NET MVC

Posted in Programming by Ari on 15 July 2010

I was recently writing a code that requires Model Binding to a list. The problem was, I didn’t have a single clue on how to pass the complex object from view to controller.
Then i came across this blog post by Phil Haack, http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx, I scanned through the code and it is actually quite simple. It is all about naming the textbox or whatever it is you use to edit.

In my case, i have a Person class which contains a list of contact objects.


 public class Person
    {
        public string Age { get; set; }
        public string Company { get; set; }
        public List Contacts { get; set; }
    }

and within the Contact list i have multiple contact like Home Contact, Office Contact, Billing Contact etc. Now, to update all three contacts at once, we must follow this naming convention. The idea is to put all of them in one form and create something that resemble this.


<form action="/Home/Update" method="post">
<!-- Office -->
    <input name="[0].Address" type="text" value="Commonwealth" />
    <input name="[0].Country" type="text" value="Singapore" />
    <input name="[0].City" type="text" value="Singapore" />

    <!-- Home -->
    <input name="[1].Address" type="text" value="Pioneer" />
    <input name="[1].Country" type="text" value="Singapore" />
    <input name="[1].City" type="text" value="Singapore" />

<!-- Billing -->
    <input name="[2].Address" type="text" value="Lakeside" />
    <input name="[2].Country" type="text" value="Singapore" />
    <input name="[2].City" type="text" value="Singapore" />

    


Notice the [0] [1] and [2] follow by name. This can be easily achieved in ASP.NET MVC 2. see below



However since I’m doing it in MVC 1, heres how i did it. Messy but it works.


<table class="firstTable">
<tbody>
            <tr><td><label>address    <td><%= Html.TextArea("["+i.ToString()+"]."+"PrimaryStreet", data.PrimaryStreet)%> </td> </tr>
            <tr><td><label>country     <td><%= Html.TextBox("[" + i.ToString() + "]." + "PrimaryCountry", data.PrimaryCountry)%> </td> </tr>
            <tr><td><label>city       <td><%= Html.TextBox("[" + i.ToString() + "]." + "PrimaryTown", data.PrimaryTown)%> </td> </tr> 
</tbody>
</table>
<input type="submit" value="Save" />

That’s it for the view and heres the controller.


        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Update(IList contact)
        {
                 ..........
        }

Alternatively we can do it with javascript. Read

Nice Web Design

Posted in WEB by Ari on 7 June 2010

niceDesign

Nice Clean design.

PSD Tutorials

Posted in WEB by Ari on 7 June 2010

CSS Sprite and Rounded Corners (with multiple CSS class)

Posted in WEB by Ari on 3 June 2010

This is how you create a rounded corners box with css sprites.

the HTML

<div class="roundedBox" id="type1">
    <strong>My content in roundedBox Type 1 </strong>

    <div class="corner topLeft"></div>
    <div class="corner topRight"></div>
    <div class="corner bottomLeft"></div>
    <div class="corner bottomRight"></div>
</div>


CSS

#type1 {background-color:#CCDEDE;}
    #type1 .corner {background-image:url(../images/corners-type1.gif);}

.roundedBox {position:relative; padding:17px; margin:10px 0;}

    .corner {position:absolute; width:17px; height:17px;}

        .topLeft {top:0; left:0; background-position:-1px -1px;}
        .topRight {top:0; right:0; background-position:-19px -1px;}
        .bottomLeft {bottom:0; left:0; background-position:-1px -19px;}
        .bottomRight {bottom:0; right:0; background-position:-19px -19px;}

Render XML-to-HTML to be included in ASP.NET MVC masterpage

Posted in Programming by Ari on 18 May 2010

Again this is not my code, original post can be found here. So in the previous post, i managed to transform from xml to html in asp.net mvc, though with that method the resulting page opens up in a new window which is not quite what i expected. With this RenderXml extension method, result page will be embedded into the master page and it looks so much better.

To do that create a static class RenderXmlExtensions, copy this code below:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.IO;
using System.Web.Mvc;
using System.Web;
using System.Xml.Xsl;

namespace MvcApplication1.Controllers
{
    /// 
    /// Provides support for rendering a XML.
    /// 
    public static class RenderXmlExtensions
    {
        #region Fields
        private static XslCompiledTransform _transparentTransform;
        #endregion

        #region Constructor
        static RenderXmlExtensions()
        {
            XmlTextReader copyTransformReader = new XmlTextReader(new StringReader("   "));
            _transparentTransform = new XslCompiledTransform();
            _transparentTransform.Load(copyTransformReader);
        }
        #endregion

        #region Methods
        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML document
        ///
The XSLT transformation
        public static void RenderXml(this HtmlHelper htmlHelper, XmlDocument xmlDocument, XslCompiledTransform transform)
        {
            RenderXmlInternal(htmlHelper, xmlDocument, null, String.Empty, transform, String.Empty, null);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML document
        ///
The XSLT transformation
        ///
The XSLT transformation arguments list
        public static void RenderXml(this HtmlHelper htmlHelper, XmlDocument xmlDocument, XslCompiledTransform transform, XsltArgumentList transformArgumentList)
        {
            RenderXmlInternal(htmlHelper, xmlDocument, null, String.Empty, transform, String.Empty, transformArgumentList);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML document
        ///
The XSLT transformation source
        public static void RenderXml(this HtmlHelper htmlHelper, XmlDocument xmlDocument, string transformSource)
        {
            RenderXmlInternal(htmlHelper, xmlDocument, null, String.Empty, null, transformSource, null);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML document
        ///
The XSLT transformation source
        ///
The XSLT transformation arguments list
        public static void RenderXml(this HtmlHelper htmlHelper, XmlDocument xmlDocument, string transformSource, XsltArgumentList transformArgumentList)
        {
            RenderXmlInternal(htmlHelper, xmlDocument, null, String.Empty, null, transformSource, transformArgumentList);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML XPath navigator
        ///
The XSLT transformation
        public static void RenderXml(this HtmlHelper htmlHelper, XPathNavigator xpathNavigator, XslCompiledTransform transform)
        {
            RenderXmlInternal(htmlHelper, null, xpathNavigator, String.Empty, transform, String.Empty, null);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML XPath navigator
        ///
The XSLT transformation
        ///
The XSLT transformation arguments list
        public static void RenderXml(this HtmlHelper htmlHelper, XPathNavigator xpathNavigator, XslCompiledTransform transform, XsltArgumentList transformArgumentList)
        {
            RenderXmlInternal(htmlHelper, null, xpathNavigator, String.Empty, transform, String.Empty, transformArgumentList);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML XPath navigator
        ///
The XSLT transformation source
        public static void RenderXml(this HtmlHelper htmlHelper, XPathNavigator xpathNavigator, string transformSource)
        {
            RenderXmlInternal(htmlHelper, null, xpathNavigator, String.Empty, null, transformSource, null);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML XPath navigator
        ///
The XSLT transformation source
        ///
The XSLT transformation arguments list
        public static void RenderXml(this HtmlHelper htmlHelper, XPathNavigator xpathNavigator, string transformSource, XsltArgumentList transformArgumentList)
        {
            RenderXmlInternal(htmlHelper, null, xpathNavigator, String.Empty, null, transformSource, transformArgumentList);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML path
        ///
The XSLT transformation
        public static void RenderXml(this HtmlHelper htmlHelper, string documentSource, XslCompiledTransform transform)
        {
            RenderXmlInternal(htmlHelper, null, null, documentSource, transform, String.Empty, null);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML path
        ///
The XSLT transformation
        ///
The XSLT transformation arguments list
        public static void RenderXml(this HtmlHelper htmlHelper, string documentSource, XslCompiledTransform transform, XsltArgumentList transformArgumentList)
        {
            RenderXmlInternal(htmlHelper, null, null, documentSource, transform, String.Empty, transformArgumentList);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML path
        ///
The XSLT transformation source
        public static void RenderXml(this HtmlHelper htmlHelper, string documentSource, string transformSource)
        {
            RenderXmlInternal(htmlHelper, null, null, documentSource, null, transformSource, null);
        }

        /// 
        /// Renders the specified XML by using the specified HMTL helper.
        /// 
        ///
The HTML helper
        ///
The XML path
        ///
The XSLT transformation source
        ///
The XSLT transformation arguments list
        public static void RenderXml(this HtmlHelper htmlHelper, string documentSource, string transformSource, XsltArgumentList transformArgumentList)
        {
            RenderXmlInternal(htmlHelper, null, null, documentSource, null, transformSource, transformArgumentList);
        }

        private static void RenderXmlInternal(HtmlHelper htmlHelper, XmlDocument xmlDocument, XPathNavigator xpathNavigator, string documentSource, XslCompiledTransform transform, string transformSource, XsltArgumentList transformArgumentList)
        {
            XPathDocument xpathDocument = null;
            //Checking if we have been given XmlDocument or XPathNavigator directly, or do we have path for document
            if ((xmlDocument == null) && (xpathNavigator == null) && (!String.IsNullOrEmpty(documentSource) && (documentSource.Trim().Length != 0)))
            {
                //Checking if path is absolute or relative
                if (!Path.IsPathRooted(documentSource))
                    //Mapping the relative path
                    documentSource = htmlHelper.ViewContext.HttpContext.Server.MapPath(documentSource);

                //Loading XML from file into XPathDocument
                using (FileStream documentStream = new FileStream(documentSource, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    XmlTextReader documentReader = new XmlTextReader(documentStream);
                    xpathDocument = new XPathDocument(documentReader);
                }
            }

            //Checking if we have been given XslCompiledTransform directly, or do we have path for transform
            if ((transform == null) && (!String.IsNullOrEmpty(transformSource) && (transformSource.Trim().Length != 0)))
            {
                //Checking if path is absolute or relative
                if (!Path.IsPathRooted(transformSource))
                    //Mapping the relative path
                    transformSource = htmlHelper.ViewContext.HttpContext.Server.MapPath(transformSource);

                //Loading XSLT from file into XslCompiledTransform
                using (FileStream transformStream = new FileStream(transformSource, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    XmlTextReader tranformReader = new XmlTextReader(transformStream);
                    transform = new XslCompiledTransform();
                    transform.Load(tranformReader);
                }
            }

            //Checking if we have XML in any form
            if (((xmlDocument != null) || (xpathDocument != null)) || (xpathNavigator != null))
            {
                //Checking if we have XSLT
                if (transform == null)
                    //If not, let's use transparent one
                    transform = _transparentTransform;

                //Perform transformation based on form in which we have our XML
                if (xmlDocument != null)
                    transform.Transform((IXPathNavigable)xmlDocument, transformArgumentList, htmlHelper.ViewContext.HttpContext.Response.Output);
                else if (xpathNavigator != null)
                    transform.Transform(xpathNavigator, transformArgumentList, htmlHelper.ViewContext.HttpContext.Response.Output);
                else
                    transform.Transform((IXPathNavigable)xpathDocument, transformArgumentList, htmlHelper.ViewContext.HttpContext.Response.Output);
            }
        }
        #endregion
    }
}

In the controller prepare an action method, which will pass our XML to view

   public ActionResult RenderXml()
        {
            XmlDocument cdCatalogDocument = new XmlDocument();
            cdCatalogDocument.Load(Server.MapPath("~/App_Data/cdcatalog.xml"));
            return View(cdCatalogDocument);
        }

And finally call the RenderXml extension method in the contentholder

   <%  Html.RenderXml((System.Xml.XmlDocument)Model, "~/App_Data/cdcatalog.xsl"); %>

Xml-to-Html with XSLT in ASP.NET MVC

Posted in Programming by Ari on 18 May 2010

This is how you write an XML-to-HTML custom actionresult using XSLT , in ASP.NET MVC. Code is not originally mine. Just copy everything and it should work.
So create a helper class and name it XmlActionresult and follow exactly as bellow.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using System.Xml.Xsl;
using System.IO;
using System.Xml.XPath;

namespace MvcApplication1.Controllers
{
    public class XmlActionResult :ActionResult
    {
     #region Fields
        private XmlDocument _xmlDocument;
        private XPathNavigator _xpathNavigator;
        private string _documentContent;
        private string _documentSource;
        private XslCompiledTransform _transform;
        private static XslCompiledTransform _transparentTransform;
        private string _transformSource;
        private XsltArgumentList _transformArgumentList;
        #endregion

        #region Properties
        /// 
        /// Gets or sets the XmlDocument to write to the response.
        /// 
        public XmlDocument Document
        {
            get { return _xmlDocument; }
            set
            {
                _xmlDocument = value;
                _documentContent = String.Empty;
                _documentSource = String.Empty;
                _xpathNavigator = null;
            }
        }

        /// 
        /// Gets or sets a string that contains the XML document to write to the response.
        /// 
        public string DocumentContent
        {
            get { return _documentContent; }
            set
            {
                _xmlDocument = null;
                _documentContent = value;
                _documentSource = String.Empty;
                _xpathNavigator = null;
            }
        }

        /// 
        /// Gets or sets the path to an XML document to write to the response.
        /// 
        public string DocumentSource
        {
            get { return _documentSource; }
            set
            {
                _xmlDocument = null;
                _documentContent = String.Empty;
                _documentSource = value;
                _xpathNavigator = null;
            }
        }

        /// 
        /// Gets or sets the XslCompiledTransform object that formats the XML document before it is written to the response.
        /// 
        public XslCompiledTransform Transform
        {
            get { return _transform; }
            set
            {
                _transform = value;
                _transformSource = String.Empty;
            }
        }

        /// 
        /// Gets or sets a XsltArgumentList that contains a list of optional arguments passed to the style sheet and used during the XSL transformation.
        /// 
        public XsltArgumentList TransformArgumentList
        {
            get { return _transformArgumentList; }
            set { _transformArgumentList = value; }
        }

        /// 
        /// Gets or sets the path to an XSL Transformation style sheet that formats the XML document before it is written to the response.
        /// 
        public string TransformSource
        {
            get { return _transformSource; }
            set
            {
                _transform = null;
                _transformSource = value;
            }
        }

        /// 
        /// Gets or sets a cursor model for navigating and editing the XML data to write to the response.
        /// 
        public XPathNavigator XPathNavigator
        {
            get { return _xpathNavigator; }
            set
            {
                _xmlDocument = null;
                _documentContent = String.Empty;
                _documentSource = String.Empty;
                _xpathNavigator = value;
            }
        }
        #endregion

        #region Constructor
        static XmlActionResult()
        {
            XmlTextReader copyTransformReader = new XmlTextReader(new StringReader("   "));
            _transparentTransform = new XslCompiledTransform();
            _transparentTransform.Load(copyTransformReader);
        }
        #endregion

        #region Methods
        public override void ExecuteResult(ControllerContext context)
        {
            XPathDocument xpathDocument = null;
            //Checking if we have been given XmlDocument or XPathNavigator directly
            if ((_xmlDocument == null) && (_xpathNavigator == null))
            {
                //Checking if we have document content
                if (!String.IsNullOrEmpty(_documentContent))
                {
                    StringReader documentReader = new StringReader(_documentContent);
                    xpathDocument = new XPathDocument(documentReader);
                }
                //Checking if we have path for document
                else if (!String.IsNullOrEmpty(_documentSource) && (_documentSource.Trim().Length != 0))
                {
                    //Checking if path is absolute or relative
                    if (!Path.IsPathRooted(_documentSource))
                        //Mapping the relative path
                        _documentSource = context.HttpContext.Server.MapPath(_documentSource);

                    //Loading XML from file into XPathDocument
                    using (FileStream documentStream = new FileStream(_documentSource, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        XmlTextReader documentReader = new XmlTextReader(documentStream);
                        xpathDocument = new XPathDocument(documentReader);
                    }
                }
            }

            //Checking if we have been given XslCompiledTransform directly, or do we have path for transform
            if ((_transform == null) && (!String.IsNullOrEmpty(_transformSource) && (_transformSource.Trim().Length != 0)))
            {
                //Checking if path is absolute or relative
                if (!Path.IsPathRooted(_transformSource))
                    //Mapping the relative path
                    _transformSource = context.HttpContext.Server.MapPath(_transformSource);

                //Loading XSLT from file into XslCompiledTransform
                using (FileStream transformStream = new FileStream(_transformSource, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    XmlTextReader tranformReader = new XmlTextReader(transformStream);
                    _transform = new XslCompiledTransform();
                    _transform.Load(tranformReader);
                }
            }

            //Checking if we have XML in any form
            if (((_xmlDocument != null) || (xpathDocument != null)) || (_xpathNavigator != null))
            {
                context.HttpContext.Response.ContentType = "text/html";

                //Checking if we have XSLT
                if (_transform == null)
                    //If not, let's use transparent one
                    _transform = _transparentTransform;

                //Perform transformation based on form in which we have our XML
                if (_xmlDocument != null)
                    _transform.Transform((IXPathNavigable)_xmlDocument, _transformArgumentList, context.HttpContext.Response.Output);
                else if (_xpathNavigator != null)
                    _transform.Transform(_xpathNavigator, _transformArgumentList, context.HttpContext.Response.Output);
                else
                    _transform.Transform((IXPathNavigable)xpathDocument, _transformArgumentList, context.HttpContext.Response.Output);
            }
        }
        #endregion
    }
}


Next on your controller:

 public XmlActionResult Test()
        {
            XmlDocument cdCatalogDocument = new XmlDocument();
            cdCatalogDocument.Load(Server.MapPath("~/App_Data/cdcatalog.xml"));

            XmlActionResult result = new XmlActionResult();
            result.Document = cdCatalogDocument;
            result.TransformSource = Server.MapPath("~/App_Data/cdcatalog.xsl");
            return result;
        }

CSS Useful posts

Posted in WEB by Ari on 16 April 2010

Recently I found this useful CSS article by Shaun Inman. The article is title CSS Qualified Selectors – some advanced CSS stuff.

Some sneek peek:

To remove the img border that
…contained checkbox is disabled? The pointer cursor is misleading (since the label’s checkbox can’t be un/checked). Currently we need to manually class the label (or disable an additional arbitrary parent element) to correct this. With Qualified Selectors (combined with attribute selectors) we could just write:

label < input[disabled]
{
cursor: default;
}

.. To differentiate the previously visited links

ul.archive li < h3 a:visited
{
opacity: 0.5;
}

To hide an empty excerpt:

div.excerpt !< * { display: none; }

Another good post would be CSS Child and sibling selector

ASP.NET MVC Useful Sites

Posted in Programming by Ari on 9 April 2010

Here are some useful sites that i would love to refer back to in the future ( coz I forget things sometimes):

Regular Expression Library

Regular Expressions Library

Validation Application Block (Ms validation Framework)

http://msdn.microsoft.com/en-us/library/dd203099.aspx

ASP.NET MVC tutorials

Contact Management System

Scott Gu MVC Store

CSS Stuff

CSS tricks

— will soon be updated when i have the time. A lot more coming!

ASP.NET MVC Menu Item Helper (selected/non-selected menu)

Posted in Uncategorized by Ari on 9 April 2010
using System;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Helpers
{
     /// <summary>
     /// This helper method renders a link within an HTML LI tag.
     /// A attribute is added to the tag when
     /// the link being rendered corresponds to the current
     /// controller and action.
     /// 
    /// This helper method is used in the Site.Master View 
   /// Master Page to display the website menu.
   /// </summary>
 public static class MenuItemHelper
 {
          public static string MenuItem(this HtmlHelper helper, string linkText, string actionName, string controllerName)
          {
                      string currentControllerName = (string)helper.ViewContext.RouteData.Values["controller"];
                      string currentActionName = (string)helper.ViewContext.RouteData.Values["action"];

                      var builder = new TagBuilder("li");
 
                     // Add selected class
                     if (currentControllerName.Equals(controllerName, StringComparison.CurrentCultureIgnoreCase) && currentActionName.Equals(actionName,StringComparison.CurrentCultureIgnoreCase))
                            builder.AddCssClass("selected");            
 
                    // Add link
                   builder.InnerHtml = helper.ActionLink(linkText, actionName, controllerName);

                   // Render Tag Builder
                   return builder.ToString(TagRenderMode.Normal);
 }

         }
}