Java Pop-up window from GridView Row Selection

Rate It (1)

Last post 03-24-2008 5:53 PM by Rivelyn. 21 replies.

Sort Posts:

  • Java Pop-up window from GridView Row Selection

    06-26-2007, 9:21 AM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    Hey all,

    I can't seem to find much working new references to this and I have tried many different way to achive this all without success, here is what I am trying to do.

    I have a gridview with a bunch of date, I would like the user to select one of the items in the gridview to be shown a detailed breakdown of the item they selected, and I would like the details to display in a pop-up window.

    So far this is as much as I have gotten, and it doesn't work. I don't think I am even close with this.

    Protected Sub GridView2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView2.SelectedIndexChanged

    Dim Key As String = GridView2.SelectedValue

    Dim ItemDetail As HyperLink = DirectCast(GridView2.FindControl("ItemDetail"), HyperLink) ItemDetail.Attributes.Add("onclick", "window.open('../ItemDetail/Default.aspx?ItemID=" & Key & "','myWindow','menubar=0,toolbar=0,height=300,width=500,resizable=0,scrollbars=0');")

    End Sub

    Any help would be great, thanks!

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 9:45 AM
    • Contributor
      2,657 point Contributor
    • DkUltra
    • Member since 03-19-2007, 2:06 PM
    • South Dakota / Nebraska
    • Posts 518

    A person could use AJax to acomplish this

    For example,

    <asp:gridviewv>
     <Columns>
    <asp:TemplateField>
    <ItemTemplate> 
    <asp:Panel ID="pnlPopup" CssClass="catdetpopup" Width="450px" runat="server" Style="display: none;"
                                        Visible="true">
    </asp:Panel>
     <cc1:ModalPopupExtender ID="mdlpopup1" runat="server" TargetControlID="btnDetails"
                PopupControlID="pnlPopup" BackgroundCssClass="popupbackground" DropShadow="true"
                                        Drag="true" PopupDragHandleControlID="dragdiv" CancelControlID="btnClose" />
     </ItemTemplate>
     </asp:TemplateField>
    </asp:Gridview>

    Hope this helps 

    DK

  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 9:48 AM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    OK so by putting this in the head of my page

    <script type= "text/javascript" language="JavaScript">

    <!-- Begin

    function popUp(URL) {day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300,left = 390,top = 362');");}

    // End -->

    </script>

    And this in my GridView Template

    <asp:TemplateField>

    <ItemTemplate><a href="javascript:popUp('../ItemDetail/Default.aspx?ItemID=')">Details</a>

    </ItemTemplate>

    </asp:TemplateField>

    I can get the desired effect, but I have no idea how to pass the ItemID value into the Url query string.

    Any suggestions?

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 9:49 AM
    Answer
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    I just started using the AJAX CP a month or so ago I have it enabled on this site. Is there something in the CP to perform this?

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 9:57 AM
    • Participant
      997 point Participant
    • robertmazzo
    • Member since 11-08-2005, 5:31 PM
    • New York, New York
    • Posts 313

     I've accomplish something similiar in the GridView (asp.net 2.0) prior to Ajax. Here's the aspx code in the gridview which display the customer's order info:

        <asp:TemplateField ItemStyle-Width="50" HeaderText="Ticket" SortExpression="ticket">
                    <ItemTemplate>
                        <asp:HyperLink ID="lnkTicketLink" runat="server"  NavigateUrl='<%# Eval("ticket", "AddModifyOrder.aspx?ticket={0}") %>' Text='<%# Eval("ticket") %>'>
                        </asp:HyperLink>
                    </ItemTemplate>
        </asp:TemplateField>

    Now in the RowDataBound event :

    <>    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                HyperLink lnkTicket = (HyperLink)e.Row.FindControl("lnkTicketLink");
                lnkTicket.NavigateUrl = "javascript:ViewOrder(" + lnkTicket.Text.Trim() + "');";

    <>         }

    <>    }

    <>
    Good luck,

    <>bob
     

  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 10:22 AM
    • Contributor
      2,657 point Contributor
    • DkUltra
    • Member since 03-19-2007, 2:06 PM
    • South Dakota / Nebraska
    • Posts 518

    The way a person could acomplish this is to put the details in a user control and pass the id in like:
    <uc1:ucxxx ID="uc" ucID='<%# Eval("ID")%>' runat="server" />
    No offense to Java Script but that isn't the old way of doing things or is it???

    DK

  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 10:37 AM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    Robert your approach is close to what I was trying to figure out, and it does pass all of the information properly. But for the life of me I can not get it to open in a popup window. It just opens in a new full size window.

    Does not seem to matter what parameters I add to the lnkTicket.NavigateUrl string to open the javascript popup window.

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 10:48 AM
    • Member
      48 point Member
    • sevs
    • Member since 09-20-2005, 6:52 PM
    • Posts 24

     I've been asking about this very thing here and sort of ran into a wall when it came to the reality of opening and closing that popup window.  I hope something can be done with AJAX since that's what I'd like to implement.

  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 10:50 AM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    Dk the problem is right now I am a little more familar with Java (not much) then I am with the workings of AJAX. The code that Robert put up is a little more familar to me and I am on a time crunch with this project I will likely look more closely into AJAX when I am finished this project.

    Robet care to take a look at what I have, or anyone else and take a guess at what I am doing incorectly.

    <ItemTemplate>

    <asp:HyperLink ID="lnkTicketLink" runat="server" NavigateUrl='<%# Eval("ItemID", "../ItemDetail/Default.aspx?ItemID={0}") %>' Text='Details' Target = "_blank"></asp:HyperLink>

    </ItemTemplate>

    Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then

    Dim lnkTicket As HyperLink = DirectCast(e.Row.FindControl("lnkTicketLink"), HyperLink)

    lnkTicket.NavigateUrl = "javascript:window.open(" + lnkTicket.Text.Trim() + "' 'MyWindow', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300,left = 390,top = 362');"

    End If

    End Sub

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 3:19 PM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    I thought maybe I had it licked with using this code on the pop-up page

    Dim ItemIDNum As String = PreviousPage.ItemID()

    And on the Sourse page I did this,

    Public Function ItemID() As String

    Return GridView2.SelectedValue

    End Function

    However this does not pass the ItemID to the destination page, my guess would be becuase the OnClientClick fires before the ItemID is assigned. Maybe this is something that is not worth the effort.

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 3:28 PM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    I forgot to add to the above post that I just created a gridview template with a standard link button and inserted the java popup code into the OnClientClick event on the asp.net page.

    My idea was the popup would happen just as a normal popup window, then the code file of the destination page would go back to the source page and extract the selected value from the gridview.

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 3:59 PM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    I went though the tutorials for the AJAX popup control extenders, and from I saw they are not what I need, they are not as flexable as creating a completely stand alone aspx page.

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-26-2007, 5:14 PM
    • Contributor
      2,657 point Contributor
    • DkUltra
    • Member since 03-19-2007, 2:06 PM
    • South Dakota / Nebraska
    • Posts 518

    That was my thought by using a usercontrol in the Ajax popup

    a usercontrol is like a standalone asp page.   

    Is a sample required?  

    DK

  • Re: Java Pop-up window from GridView Row Selection

    06-27-2007, 8:24 AM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    Morning,

    Hey DK a sample would be great, since I am not following what you mean.

    A friend pointed out the option of possible using a floating div, another friend gave me an option that I am pretty sure will work and if all else fails I will do it, but I think it's going to end up being a lot of coding and rather messy.

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
  • Re: Java Pop-up window from GridView Row Selection

    06-27-2007, 9:20 AM
    • Participant
      1,020 point Participant
    • Rivelyn
    • Member since 06-20-2006, 5:57 PM
    • Posts 532

    So I found this tid-bit of code on some obscure forums that apparently does the trick of passing a value to a java popup window here is is.

    <ItemTemplate>

    <a href="javaScript:openWin('../ItemDetail/Default.aspx?ItemID=<%=rsSearch("ItemID")%>','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0')">Details</a>

    </ItemTemplate>

    The only problem is I have no idea what the code is referencing here rsSearch

    www.someguy.ca rantings from some Canadian guy
    Follow me on twitter as well twitter.com/SomeCanadianGuy
Page 1 of 2 (22 items) 1 2 Next >