Solved

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

Posted on 2012-03-09
2
267 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now