Closed Thread
Results 1 to 4 of 4

Thread: Dynamic Content in AJAX Extender

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    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 12:37 PM. Reason: Removed [SOLVED] from title

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    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

  3. #3
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    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. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Cheers mate, glad I could help

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO