Solved

convert checkbox code to link in asp.net and c#

Posted on 2012-03-09
2
275 Views
Last Modified: 2012-03-26
hi,

I want to convert checkbox into link. Clicking on checkbox will expand/collapse table. How the below can be converted if the checkbox is a link.

<asp:CheckBox id=chkExpandView runat="server" Font-Names="Arial" Font-Size="X-Small" AutoPostBack=true  OnCheckedChanged="chkExpandView_CheckedChanged" />
                    <font size="2" face="Arial"> <b>Expand All</b></font>

C#
 protected string DisplayScriptExpandCollapse()
    {
        if (this.chkExpandView.))
            return "display:block;";
        else
            return "display:none;";
            }
0
Comment
Question by:Saroj13
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37705026
Do you want the CheckBox to use an <anchor> style, or change the CheckBox to a HyperLink control?
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 37705052
You could use a asp:LinkButton:

<asp:LinkButton ID="hlExpandView" runat="server" CommandName="Display" CommandArgument="Expand" Text="Expand All" Font-Size="12" Font-Bold="true" OnCommand="hlExpandView_Command"></asp:LinkButton>

Then in code behind:

        protected void hlExpandView_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandArgument.ToString() == "Expand")
            {
                myTable.Visible = true;  //your table name here
                hlExpandView.CommandArgument = "Collapse";
            }
            else
            {
                myTable.Visible = false;   //your table name here
                hlExpandView.CommandArgument = "Expand";
            }
        }
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question