Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add image dynamically based on count

Status
Not open for further replies.

divya1112

Programmer
Sep 1, 2011
1
0
0
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

 
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)
{
[tab]if(c.GetType() == "CheckBox")
[tab]{
[tab]CheckBox ck = (CheckBox)c;
[tab]if(ck.Checked)
[tab][tab]{
[tab][tab]imgPanel.Controls.Add(new Image('mygif.png'));
[tab][tab]}
[tab]}
}

Lod

You've got questions and source code. We want both!
 
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
forum216
forum855
depending on the technologies used.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top