DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Dynamic Content in AJAX Extender

This is a discussion on Dynamic Content in AJAX Extender within the .Net Development forums, part of the Programming & Scripting category; I have a datalist that contains an imagebutton control. I've added an AJAX confirm button extender to this imagebutton, but ...

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

  #1  
Old March 17th, 2008, 11:53 AM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,342
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default Dynamic Content in AJAX Extender

I have a datalist that contains an imagebutton control. I've added an AJAX confirm button extender to this imagebutton, but I want to dynamically change the confirm text depending on the datalist item.
My datalist code is:-
Code:
<asp:datalist ID="dlst_userlist" runat="server" OnItemDataBound="dlst_userlist_ondatabind" OnEditCommand="dlst_remove_user" CssClass="registerform">
<ItemTemplate>
<tr><td valign="middle"><asp:label ID="lbl_username" runat="server" cssclass="dblue8" Text='<%#Eval("full_name") %>' /></td><td valign="middle"><asp:ImageButton ID="img_remove_user" ImageUrl="link_doc_remove1.gif" CommandName="Edit" CommandArgument='<%#Eval("linkref") %>' runat="server" /></td></tr>
<ajaxtoolkit:ConfirmButtonExtender ID="conf_remove_user" runat="server" ConfirmText='Are you sure you wish to remove <%#Eval("full_name") %> from this task?' TargetControlID="img_remove_user" />
</ItemTemplate>
</asp:datalist> 
I tried creating an instance of the extender in my onitemdatabound routine, like this:-
Code:
e.Item.FindControl("conf_remove_user").confirmtext = "Are you sure you want to remove " & e.Item.DataItem("full_name") & " from this task?" 
but it says confirmtext is not a member of 'System.Web.UI.Control'. I can't create an instance of the object type within the routine, because it doesn't seem I can create an ajaxtoolkit object, such as Dim username as confirmbuttonextender, for example.

At the moment if you click the button the confirm text is "Are you sure you wish to remove <%#Eval("full_name") %> from this task?"

I want it to say "Are you sure you wish to remove Joe Bloggs from this task?"

Any ideas how to dynamically change this text?

Thanks

Last edited by richyrich; May 6th, 2008 at 11:37 AM. Reason: Removed [SOLVED] from title
  #2  
Old March 17th, 2008, 12:01 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Try creating an instance like so:

Code:
Dim btnExtender As AjaxControlToolkit.ConfirmButtonExtender
btnExtender = CType(e.Item.FindControl("conf_remove_user"), AjaxControlToolkit.ConfirmButtonExtender) 
I haven't done this before, so not sure. Let me know how it goes

Comments on this post
richyrich agrees: Excellent. Exactly what I was after....
AOG123 agrees: Good Work jmh,
  #3  
Old March 17th, 2008, 12:12 PM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,342
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default

Perfect. It was the ajaxcontroltoolkit.confirmbuttonextender that I didn't know I could do.
Solution:
Code:
Dim btn_extender as AjaxControlToolkit.ConfirmButtonExtender = e.item.findcontrol("conf_remove_user")
btn_extender.ConfirmText = "Are you sure you want to remove " & e.Item.DataItem("full_name") & " from this task?"
Thanks J...
  #4  
Old March 17th, 2008, 12:14 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Cheers mate, glad I could help
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:07 AM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2