Ajax Datalist with modalpopup

Last post 12-01-2009 1:42 PM by Sonu. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-27-2009 12:03 PM

    • yzidell
    • Top 50 Contributor
    • Joined on 09-21-2006
    • Wannabe Slacker
    • Points 532

    Ajax Datalist with modalpopup

    Hi,

    I am using the ajaxa datalist and works very well.

    I would like to add a button to call a ModalPopup via javascript and to pass in a value.

    The modalpopup would then contain a grid to vie and update data on the server.

    How would I accomplish this??

    Thanks

     

  •  Advertisement

    Featured Advertisement

     
  • 11-27-2009 12:17 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Ajax Datalist with modalpopup

    You should use the ItemDataBound event to get the item. Then use the item.findControl to find the appropriate item to set the js function. This should help:

    function onItemDataBound(sender, e)
    {
      var item = e.get_item();
      if (item.get_isDataItemType())
      {
        var element = item.findControl("NameOfTheControl");  // You need to set the control in the designer
        element.onClick = function() { doSomething() };
      }
    }

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 11-28-2009 9:41 PM In reply to

    • yzidell
    • Top 50 Contributor
    • Joined on 09-21-2006
    • Wannabe Slacker
    • Points 532

    Re: Ajax Datalist with modalpopup

    Hi,

    Thanks for replying.

    Can you please elaborate some more??

    Thanks

  • 11-30-2009 9:48 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Ajax Datalist with modalpopup

    Take a look at the onItemDataBound function in this example:

    http://dotnetslackers.com/projects/AjaxDataControls/SourceCode.aspx?url=/projects/AjaxDataControls/DataList/Basic.aspx

    Now we can make the following additions

    var spnUnitPrice = item.findControl('spnUnitPrice'); // this line is already there.
    spnUnitPrice.onClick = function() { showModal() };  // add the onclick handler

    And your showModal() function would then simply show the modal. If you were using jquery your function would look like this:

    function showModal()
    {
      $("#dialog").dialog();
    }

    Let me know if you need more help :)

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 12-01-2009 1:35 PM In reply to

    • yzidell
    • Top 50 Contributor
    • Joined on 09-21-2006
    • Wannabe Slacker
    • Points 532

    Re: Ajax Datalist with modalpopup

    Hi,

    I am having a problem - when I add the ModalPopupExtender and panel to the page, the datalist does show or appear.

    <asp:Button ID="btnShowEditGuestPopup" runat="server" Text="show" style="visibility:hidden;" />
                <ajaxToolKit:ModalPopupExtender
                                ID="mpeEditGuest" runat="server" BehaviorID="mpeEditGuest" TargetControlID="btnShowEditGuestPopup"
                                PopupControlID="pnlEditGuestPopup" BackgroundCssClass="modalBackground" PopupDragHandleControlID="tblEditGuestHeader"
                                Drag="true" OkControlID="btnEditGuestClose" CancelControlID="lnkBtnEditGuestTopClose"
                                RepositionMode="RepositionOnWindowResizeAndScroll" />
                             <asp:Panel ID="pnlEditGuestPopup" runat="server" style="display:none">
                                <div id="divEditGuest" style="background-color:White; border:solid 4px #507CD1; width:100px; height:70px;">
                                    <div>stuff</div>
                                </div>
                            </asp:Panel>

    Thanks for your help.

     

  • 12-01-2009 1:42 PM In reply to

    • Sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Ajax Datalist with modalpopup

    Ah. I did not know that you were using the ModalPopupExtender. You can not add the control to the datalist like that. You have to do that from the client-side via java script. Here is an example how to achieve this. Its pretty straight forward.

    http://ajaxdatacontrols.codeplex.com/SourceControl/changeset/view/32283#187627

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
Page 1 of 1 (6 items)