Showing posts with label itemtemplate. Show all posts
Showing posts with label itemtemplate. Show all posts

Monday, March 26, 2012

Connect AnimationExtender at runtime

Hi,

I have created a page with a datalist that has a button and a image inside the itemtemplate. So what I trying to do is to connect the animationextender with the button (targetid) at runtime, wich does not work at all. Is it possible to connect (set target id) at runtime or must it be done in designtime?

//CC

Hi TCNC,

The Animation Framework has a n undocumented feature wherein any attribute assigned to the AnimationExtender is evaluated at runtime .

You can use it by suffixing the Attribute with the Attribute "Script"

EX: < ajaxToolkit:AnimationExtender Blah>

<OnClick>

<Resize Height="200" width="200" AnimationTargetScript="getTargetElement();" />

</OnClick>

</ajaxToolkit:AnimationExtender>

<script language="Javascript">

function getTargetElement(){

return someelementID;

}

</script>

This will cause the function getTargetElement to be called whenever the Animation is played.

You can probably set the ID of the Element to be animated in a hidden field.

In the Function "getTargetElement" read the HiddenField and return its value.

When the Animation plays , the target is automatically changed.

Hope this helps.

And if it resolves the issue , Please mark my reply as the answer

ConfirmButtonExtender with GridView

I have a LinkButton in a gridview that acts as a select, and I was hoping to use the ConfirmButtonExtender. I tried it in the ItemTemplate for that column, but it gave me an error that it can't find a control with the ID. Is there any way to use that with a button in a gridview? If so, where does the extender need to be?I think you can just drop the extender in the template, but if that doesn't work, I believe this has been covered elsewhere on this forum. Once the search feature is working again it shouldn't be too difficult to find, I hope.
I ended up using a javascript confirm box this time, but I will probably look into it again next time I need to.

Hey medenn, can you share your code? thanksSmile


OnClientClick="javascript:void_confirm=confirm('Message Here');return void_confirm;"

ConfirmButtonExtender error when in ItemTemplate

I cannot get the ConfirmButtonExtender to work in a DataList ItemTemplate. I get the infamous error can't find control id (of the target control of course).

I checked all the normal causes and I don't see what is wrong. They are both in the item template, hence the same naming container.

Here is a sample of what I have:

 <asp:DataList ID="relList" runat="server" BorderColor="#5377A9" BorderStyle="Double" Width="100%" ExtractTemplateRows="True" OnItemCreated="relList_ItemCreated"> <ItemTemplate> <asp:Table ID="tblSubFMEAs" runat="server"> <asp:TableRow ID="SubFMEARow" runat="server"> <asp:TableCell ID="SubFMEANameCell" runat="server" Width="80%"> <div style="padding:2px; vertical-align: middle; text-indent: 10px;"> <asp:linkbutton ID="nameLabel" runat="server" Text='<%# GetLinkLabelText(Container)%>' CommandName="Edit" /><br /> </div> </asp:TableCell> <asp:TableCell ID="RemSubFMEACell" runat="server" Width="20%" HorizontalAlign="Right"> <div style="padding:2px; vertical-align: middle; direction: rtl; text-indent: 10px;"> <asp:LinkButton ID="RemoveSubFMEA" runat="server" Text="Remove" CommandName="Remove" /> <cc1:ConfirmButtonExtender ID="confirmRem" runat="server" TargetControlID="RemoveSubFEMA" /> </div> </asp:TableCell> </asp:TableRow> </asp:Table> </ItemTemplate> <FooterTemplate> <asp:Table ID="tblSubFMEAsFooter" runat="server"> <asp:TableRow ID="SubFMEAFooterRow" runat="server"> <asp:TableCell ID="FooterCell" runat="server"> <img alt=" " src="images/dot.gif" height="1" /> </asp:TableCell> </asp:TableRow> </asp:Table> </FooterTemplate> </asp:DataList>

Hi CHolt,

there are two issues...

1. The ConfirmButtonExtender cant put in the <ItemTemplate> , you need to move it out of DataList. Otherwise you error on Design View

2. Once you move it out of DataList, you will getThe TargetControlID of 'confirmRem' is not valid. A control with ID 'RemoveSubFMEA' could not be found.

This is because the DataList created after ConfirmButtonExtender generated. So it can not find the TargetControlID. To walkwround it you may add ConfirmButtonExtender by code. Add it on page_Load

Hope this help


On thing that confuses me about your solution is that the button will be repeated. How is the extender going to work with multiple targets?

I would think that this is the most common use of the confirmbuttonextender to have a confirm dialog on the delete "button" of a row in a datalist or gridview. Is there any examples out there that have this working?

Thanks

Wednesday, March 21, 2012

Compilation error UpdatePanel in Repeater

Hi,

I have a repeater with ItemTemplate and AlternativeTemplate. Within the repeater there is a Table. Inside of one of the <td> I have UpdatePanel, so in the ItemTemplate there is an UpdatePanel1 and there is another one in the AlternativeTemplate with the same ID name, I thought this won't have any conflict since we can put two controls with same ID as long as they are in the different Template. But I got this error :

Description:Anerror occurred during the compilation of a resource required to servicethis request. Please review the following specific error details andmodify your source code appropriately.

Compiler Error Message:CS0102: The type 'NamespaceName' already contains a definition for 'A_ControlName'

any help would be great.

thanks

I had a very similar problem - had a datalist where each itemtemplate contained an updatepanel.Inside the itemtemplate was a control called "selDriver", and on the main page there was also a control called "selDriver" - this was never a problem until the updatepanel was added in, and then it broke the compilation.I had to change the control's name in the main page to something different (which in retrospect I should have done anyway!) so I suspect you are experiencing something similar.Good luck!

Try to do with different name for both controls