×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

add image dynamically based on count

add image dynamically based on count

add image dynamically based on count

(OP)
hi,

suppose I have 5 check boxes. Based on number of check box checked I have to add image and hyper-link to images. (i.e if I have checked 2 check box I have to load only 2 image and link to those 2 loaded images, in-case of 3 check box checked, 3 images needs to be loaded and link to those 3 loaded images).

Is there any possible way that i can do that in asp.net using c#?



thanks

 

RE: add image dynamically based on count

spool the controls in the form, tally how many controls are checkboxes, that are checked.

I'm assuming there's some logic to which images to load based on which checkbox is selected. Normally you can either put this data point in the text property of the check box, but you may need to do something with the name of the control.

PSEUDO CODE!!!
foreach(Control c in Page.Controls)
{
    if(c.GetType() == "CheckBox")
    {
    CheckBox ck = (CheckBox)c;
    if(ck.Checked)
        {
        imgPanel.Controls.Add(new Image('mygif.png'));
        }
    }
}

Lod

You've got questions and source code. We want both!

RE: add image dynamically based on count

of course it's possible. how you solve this depends on a couple factors though.
1. are you using webforms or MVC (monorail, fubu, ms mvc, open rasta)?
2. when/where do you want to create the links/images? in other words what is the UX or process flow?

these factors will determine if you should leverage C# (server) or javascript (client). You will probably leverage both, but to what extent.

being that you are directly talking about a web application and manipulating the view your best bet for help will be in
forum215: HTML, XHTML & CSS
forum216: Javascript
forum855: Microsoft: ASP.NET
depending on the technologies used.

Jason Meckley
Programmer

FAQ855-7190: Database Connection Management
FAQ732-7259: Keeping the UI responsive

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close