c# - Remove images appearing on the aspx page -
i created imagebuttons in code-behind. then, populated list of imagebuttons as:
protected void image_click(object sender, imageclickeventargs e) { imagebutton imgbutton = sender imagebutton; imgbutton.imageurl = resource.tick_image; // work imagebuttonlist.add(imgbutton); }
on aspx page images appear now. after time, want remove images.
i tried like:
buttonlist.clear();
but, still images appearing on aspx page. how should remove images?
my whole code looks like:
public static list<image> randomimages = new list<image>(); protected void page_load(object sender, eventargs e) { buttonlist.clear(); if (!string.isnullorempty(request.form[resource.reset_button_id]) || !page.ispostback) { randomimages = resetgame(); } addcardstodisplay(randomimages, carddiv, true); } public void addcardstodisplay(list<image> images, system.web.ui.htmlcontrols.htmlgenericcontrol divisionname, bool isclickable) { foreach (var image in images) { imagebutton button = utilities.createimagebutton(image.newimageurl, image.id, carddiv); addimagebuttonclickevent(button, isclickable); } } protected list<image> resetgame() { numberofclicks = 0; return getrandomimages(number_of_images); } public static imagebutton createimagebutton(string imageurl, string id, system.web.ui.htmlcontrols.htmlgenericcontrol divisionname) { imagebutton button = new imagebutton { imageurl = imageurl, id = id }; divisionname.controls.add(button); return button; }
just use command "clear" list. empty usages pf buttons. instead of foreach loop
imagebuttonlist.clear();
and should work. :-)
edit
i thought imagelist parent of controls. not seem case.
if want remove button itself, try as:
imgbutton.parent.controls.remove(imgbutton);
if want hide them. do
imgbutton.visible = false;
last not least. can reset image url, set null. , shouldmt visible (not sure if give red x though)
Comments
Post a Comment