开发者

Disabling a row in table depending on the web page you are in

I have a table as side bar in the master page which is coded as follows in webstore.master

 <div class="Sidebar" runat="server">
        <table width="140px" border="0" cellpadding="2" cellspacing="2">
            <tbody>
                <tr>
                    <td class="LeftButton">
                        <a class="LeftButton" href="Home.aspx">Continue Shopping</a>
                    </td>
                </tr>
            </tbody>
            <tr>
                &开发者_开发技巧lt;td class="LeftButton">
                    <a class="LeftButton" href="ShoppingCart.aspx">Edit Shopping Cart</a>
                </td>
            </tr>
            <tr>
                <td class="LeftButton">
                    <a class="LeftButton" href="CheckOut.aspx">Check Out</a>
                </td>
            </tr>
            <tr>
                <td class="LeftButton">
                    <a class="LeftButton" href="MySoftware.aspx">My Software</a>
                </td>
            </tr>
        </table>
    </div>

I inherit this onto every other content page in the project. But now i want to disable a specific row depending upon the page i'm in.

For example if i'm in home.aspx i want to disable the row titled "Continue Shopping". similary if i'm in Checkout.aspx i want to disable the row titled "Check out"

How can i achieve this.

BTW i'm using VS 2008, asp.net/c#

Thanks in anticipation


This is the simple solution:

<div class="Sidebar" runat="server">
        <table width="140px" border="0" cellpadding="2" cellspacing="2">
            <%if(!Request.Url.ToString().Contains("home.aspx")){%>
              <tbody>   
                <tr>
                    <td class="LeftButton">
                        <a class="LeftButton" href="Home.aspx">Continue Shopping</a>
                    </td>
                </tr>
            </tbody>
            <%}%>
            <tr>
                <td class="LeftButton">
                    <a class="LeftButton" href="ShoppingCart.aspx">Edit Shopping Cart</a>
                </td>
            </tr>
           <%if(!Request.Url.ToString().Contains("CheckOut.aspx")){%>
            <tr>
                <td class="LeftButton">
                    <a class="LeftButton" href="CheckOut.aspx">Check Out</a>
                </td>
            </tr>
            <%}%>
            <tr>
                <td class="LeftButton">
                    <a class="LeftButton" href="MySoftware.aspx">My Software</a>
                </td>
            </tr>
        </table>
    </div>

You get the idea.

Otherwise make a control that does the same thing in codebehind. that would be a bit more elegant, but basicly the same. :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜