Solved

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

773 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