Window from GridButton in MultiPage

6 posts, 1 answers
  1. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 22 Sep 2011 Link to this post

    Hi,

    MasterPage>Default.aspx>MainUserControl.ascx

    MainUserControl.ascx has a tabstrip and multipage which in turns holds 5 other user controls each having a RadGrid.

    On each grid I need to open a window from one of the grid columns and pass through the row a data item.

    I have tried from your examples both using the javascript function called from the ItemCreated event and also direct from code behind.
    In some cases this works but not always and not on every grid.

    I've tried changing viewstate, adding and taking away window managers and everything else I can think of.
    Is there a prescribed method or sample that will show this functionality please?

    Thanks,
    Jon
  2. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 22 Sep 2011 Link to this post

    Does the window open in IFrame mode (ContentURL), or is it a ContentTemplate implementation?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 23 Sep 2011 Link to this post

    Hi Steve - Thanks for the reply.

    I use the iFrame mode, NavigateURL -  not a content template in the page.

    Cheers,
    Jon
  5. Answer
    Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 23 Sep 2011 Link to this post

    What I would do is have every grid have a button column, and on click of that button call a single function in the (master) ascx control, passing in the data you need.

    So then inside that click event you set the window content url and pass the data along the querystring

    <script type="text/javascript">
    function openWindow(data){
        //get the window
         var window = $find('<%= RadWindow1.ClientID %>');
         window.setUrl("http://www.site.com/detailspage.aspx?id=" + data);
         window.show();
    }
    </script>

    Or perhaps you just handle a clientside grid row selected event
    function ActiveRowChanged(sender, eventArgs) {
         
    }

    ...and get access to the rows dataitem that way?
    var dataItem = eventArgs.get_gridDataItem());
    //or perhaps pass the dataItem to the windowOpen function above...?
    There's lots of ways to do it, but I prefer the clientside, just way more slick for the users instead of postbacks.  The only complex part I see is getting the data you need to pass down to the function somehow.

    If you do choose to use a button to pass args might I suggest the RadButton as you can assign CommandArgs to it which you have easy access to on the clientside.  So in the clicking event of the radbutton you just need to do: var data = args.get_commandArgument(); which would contain the dataitems you need to pass.
  6. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 26 Sep 2011 Link to this post

    Fantastic Steve,

    I tried with the RadButton but couldn't pass the data item - I'll keep at looking at that, but I did it this way in the end.

    In the holding ascx page...
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
     
    function openWindow(data){
     
        //get the window
     
         var window = $find('<%= RadWindow1.ClientID %>');
         
         window.setUrl("modals/Details.aspx?jID=" + data);
     
         window.show();
     
    }
     
    </script>
    </telerik:RadCodeBlock>

    Then in any Grid Template used this..

    <a href="#" onclick="openWindow('<%# DataBinder.Eval(Container.DataItem, "ID") %>'); return false;">
    <asp:ImageButton ID="btntest" runat="server"  ImageUrl="~/images/icons/messages.png" />
    </a>

    Great stuff, all working nicely on the client.
    Thanks ever so much for your help!

    Cheers,
    Jon
  7. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 26 Sep 2011 Link to this post

    Glad I could help :)

    If it's not too much trouble, do you mind marking the post as answered for me? :)
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017