Showing posts with label images. Show all posts
Showing posts with label images. Show all posts

Wednesday, March 28, 2012

Dynamic Content events needed as Trigger events

Is there a way to add triggers at runtime? I have a bunch of dynamic images that show that I want to add the click events as triggers to update a larger image. Thanks.

I don't think you can add triggers dynamically (maybe it's possible, I don't see a way however).

The best way to procede depends on your needs. If *all* you need is your UpdatePanel to update() when some image is clicked and you don't know what / how many images at runtime, you could just dynamically add the image controls to the UpdatePanel's container controls, and give each image an onclick attribute with a postback reference. Something like this:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><script runat="server"> protected void Page_Load(object sender, EventArgs e) { Image Image1 = new Image(); UpdatePanel1.ContentTemplateContainer.Controls.Add(Image1); Image1.ID = "Image1"; Image1.ImageUrl = "img.png"; Image1.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(Image1, "Image1PostBack")); }</script><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" > <ContentTemplate> asdf </ContentTemplate> </asp:UpdatePanel> </form></body></html>
 

If the dynamic images need to be outside the UpdatePanel you want to trigger - does it matter to your update which dynamic image was clicked? Depending on that, there are other possibillities.

Ben


Ben,

Thanks for the post. I figured it out. You can add triggers to the updatepanel.

Dim x As New AsyncPostBackTriggerx.ControlID = <name of control that will be doing the update>x.EventName = "Click"update.Triggers.Add(x)

Just make sure this runs even after a post back.

Monday, March 26, 2012

dynamic addhandler not working in update panel

hi all,

i have designed a page, with a place holder in it, the placeholder is inside a updatepanel, the placeholder gets filled with images at load, and when i click the viewcart button it get filled with the image information with few dynamic buttons, i have added addhandler for those buttons, but they are not firring up. i am pasting my code here if some one can help me plz.

Dim

updateorderlnkbtn AsNew button ' this is done at the genearal section of the page to make it globalAddHandler updateorderlnkbtn.click,AddressOf cancelBtn_click ' at page init

please help me

hi all

i have done some other changes to the code but still the same problem, if any one of you can give me some idea that would be highly appreciated

thanks


hi all

I have done some thing here that my 5 static buttons that are created at runtime are working fine now but the problem is with the dynamic table, i am placing a delete button in the dynamic table now the dynamic table is created at runtime and i want the delete button to remove the row.

the other buttons (5 buttons) code is something like this , i have wrote the code behing the load, the problem is that i can't wrote the dynamic table code behind the load, the dynammic table is created when i click a viewcart button

please help