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:

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

    06-27-2007, 9:53 AM
    • Loading...
    • DkUltra
    • Joined on 03-19-2007, 2:06 PM
    • South Dakota / Nebraska
    • Posts 304

    Hi, the following is a complete sample.  I would assume rsSearch is a function defined as <script>  rsSearch(var id) {     }   </script>  

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" DataKeyNames="CategoryID" DataSourceID="ObjectDataSourceCategory"
                        CellPadding="4" ForeColor="#333333" GridLines="None" Font-Size="8pt" Font-Names="Verdana"
                        Width="100%" EmptyDataText="There are no categories defined" PageSize="10">
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnDetails" runat="server" Text="Details" CausesValidation="false" />
                                    <asp:LinkButton ID="btnDelete" runat="server" Text="Delete" CausesValidation="false"
                                        CommandName="Delete" />
                                    <asp:Panel ID="pnlPopup" CssClass="catdetpopup" Width="450px" runat="server" Style="display: none;"
                                        Visible="true">
                                        <div style="width: 100%; height: auto; background-repeat: repeat-x; color: Black;
                                            font-family: Calibri" id="dragdiv" runat="server">
                                            <div style="float: right">
                                                <asp:Image runat="server" ID="btnClose" ImageUrl="/globalimages/close_button.gif" />
                                            </div>
                                            <div style="padding: 10px">
                                              <uc1:ucCategoryDetails ID="CategoryDetails1" Cat_id='<%# Eval("CategoryID")%>' runat="server">
                                                </uc1:ucCategoryDetails>
                                            </div>
                                        </div>
                                    </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:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"
                                Visible="False" ReadOnly="True" SortExpression="CategoryID" />
                            <asp:BoundField DataField="CategoryName" HeaderText="Category Name" SortExpression="CategoryName" />
                            <asp:CheckBoxField DataField="IsActive" HeaderText="Active" SortExpression="IsActive" />
                        </Columns>
                       
                    </asp:GridView>
    Css
    .catdetpopup
    {
        width:500px;
        height:auto;
        border:1px solid black;
        background-color:White;
    }
    UserControl codebehind

    Partial Public Class ucCategoryDetails
        Inherits System.Web.UI.UserControl
        Private _Cat_ID As String
        Public Property Cat_id() As String
            Get
                Return _Cat_ID
            End Get
            Set(ByVal value As String)
                _Cat_ID = value
                Me.odsSubCat.SelectParameters("Cat_ID").DefaultValue = CInt(Cat_id)
              
            End Set

        End Property
    End Class

    Hope this Helps

    DK

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

    06-27-2007, 11:04 AM
    • Loading...
    • Rivelyn
    • Joined on 06-20-2006, 5:57 PM
    • Posts 460

    Thanksd to this post http://forums.asp.net/t/1126878.aspx

    I think I am getting closer.

    So far Source Page has these peices of code,

    <script type="text/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>

    Followed by the gridview template.

    <ItemTemplate>

    <asp:HyperLink ID="idTracking" runat="server" Style="position: relative" Text='<%# Eval("ItemID") %>' NavigateUrl="popUp('../ItemDetail/Default.aspx?ItemID=')"></asp:HyperLink>

    </ItemTemplate>

    Followed by the VB code behind.

    Protected Sub GridView2_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView2.RowDataBound

    If e.Row.RowType = DataControlRowType.DataRow Then

    Dim hl As HyperLink = DirectCast(e.Row.FindControl("idTracking"), HyperLink) hl.NavigateUrl = "javascript:" + hl.NavigateUrl

    End If

    End Sub

    But still the illusive thing is just getting the ItemID into the Url Query string, why is this so difficult it makes me shake my head I can't be the only person in the world trying to do this...lol

    www.mogspace.com for online gamers
  • Re: Java Pop-up window from GridView Row Selection

    06-27-2007, 11:07 AM
    • Loading...
    • Rivelyn
    • Joined on 06-20-2006, 5:57 PM
    • Posts 460

    Thanks DK, I will give this a go. Seems we are posting at the same time.

    www.mogspace.com for online gamers
  • Re: Java Pop-up window from GridView Row Selection

    06-28-2007, 4:42 PM
    • Loading...
    • Rivelyn
    • Joined on 06-20-2006, 5:57 PM
    • Posts 460

    OK partially thanks to this post http://forums.asp.net/t/1126878.aspx I was able to figure this out and it works like a charm.

    Fist I replace my Gridview with a Repeater, I just created the same look as the gridview using a table then dropped the table into the Repeater template.

    It looks like so,

    <asp:Repeater ID="ItemData" runat="server">

    <ItemTemplate>

    <table border="0" cellpadding="0" cellspacing="0" style="width: 95%; position: relative;">

    <tr>

    <td align="left" style="border-bottom: dimgray 1px dotted" valign="middle">

    <asp:LinkButton ID="ItemLink" runat="server" OnClientClick='<%# Eval("ItemID") %>'

    Style="position: relative" Text='<%# Eval("ItemName") %>'></asp:LinkButton>

    </td>

    </tr>

    </table>

    </ItemTemplate>

    </asp:Repeater>

    And the code beside looks like this,

    Protected Sub ItemData_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles ItemData.ItemDataBound Dim hl As LinkButton = DirectCast(e.Item.FindControl("ItemLink"), LinkButton)

    hl.OnClientClick = "javascript:window.open('../ItemDetail/Default.aspx?ItemID=" & hl.OnClientClick & "', 'MyWindow', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,location=0,left = 390,top = 362,width=500,height=300');"

    End Sub

    When the link button is clicked it runs the window.open command and inserts the ItemID

    Thanks Everyone!

    www.mogspace.com for online gamers
  • Re: Java Pop-up window from GridView Row Selection

    07-03-2007, 1:00 PM
    • Loading...
    • robertmazzo
    • Joined on 11-08-2005, 5:31 PM
    • New York, New York
    • Posts 284

     My appologies for not having seen your response to me. I'll just post the ViewOrder js routine that I use :

     

    function ViewOrder(nOrder, SubmitType){
        var hidClient  = document.getElementById(hidClientAliasID);
        var hidUser_Id = document.getElementById(hidUser_IdAliasID);
        var cClient  = hidClient.value;
        var cUser_Id = hidUser_Id.value;
        var cBranch  = "";
        var WindowName = (SubmitType == "New" ? "SubmitNew" : "SubmitCancel");
        //window.alert(nOrder + "/" + SubmitType);   
        OrderModWin = window.open("AddModifyOrder.aspx?ticket=" + escape(nOrder) + "&branch=" + escape(cBranch) + "&client=" + escape(cClient) + "&user_id=" + escape(cUser_Id), WindowName, 'scrollbars=no,toolbar=no,height=410,width=880,alwaysRaised=yes,resizable=yes,location=no, status=no,screenX=400,screenY=410');
    }
     

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

    03-20-2008, 2:29 PM
    • Loading...
    • nd
    • Joined on 09-11-2002, 8:09 AM
    • Posts 12

    This used to be easy with the datagrid:

              <asp:HyperLinkColumn HeaderText="Product" DataNavigateUrlField="catalog_number" DataNavigateUrlFormatString="javascript:window.open('detail.aspx?id={0}',dtl,'width=400,height=300,location=no')" DataTextField="catalog_number" />  

    But not the gridview's HyperLinkField:

              <asp:HyperLinkField HeaderText="Product"   DataNavigateUrlFields="catalog_number" DataNavigateUrlFormatString="javascript:window.open('detail.aspx?id={0}',dtl,'width=400,height=300,location=no')" DataTextField="catalog_number" />  

    Unfortunately, it doesn't work with the gridview's hyperlinkfield.  The suggestions in the thread seem like an awful lot of overhead for simple functionality. Am I missing an option in my HyperLinkField?

     

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

    03-24-2008, 5:53 PM
    • Loading...
    • Rivelyn
    • Joined on 06-20-2006, 5:57 PM
    • Posts 460

    The code is a little complex because you have to remember that you are not dealing with only 1 hyperlink, you are actually dealing with a number of dynamically generated hyperlinks, based on how many records are being displayed.

    So you need to interact with each hyperlink as it is generated.

    www.mogspace.com for online gamers
Page 2 of 2 (22 items) < Previous 1 2
Microsoft Communities
Page view counter