Solved

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

Posted on 2012-03-09
2
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting PHP triple des decrypt to c# 9 167
parse string in c# 5 41
Access-Control-Allow-Origin 4 45
.NET Redemption/Outlook Examples 3 32
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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