ASP.net Popup Window

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
I've got no real understanding of java so i'm looking for some help here.

All I want to do it popup a new window that will show some data when a user clicks "View More".

This will mean passing a ID value from a GridView Row into the popup page.

Can anyone help with this?
 
I can do it but it depends what your attaching the Javascript too... for example, is it to a button in a gridview or just a button in the page?

Stelly
 
Something like this:

Code:
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridView GdVwReview = (GridView)ClientFrmVw.FindControl("GridView1");

        int index = Convert.ToInt32(e.CommandArgument);

            string value = GdVwReview.DataKeys[index].Value.ToString();
            string xScript = "<script language='javascript'>window.open('xxxxxx.aspx?xxx=" + value + "',name='_blank','scrollbars=0,width=800,HEIGHT=460');</script>";
            Page.RegisterStartupScript("PopUpWindowSoft", xScript);

    }
 
Ok I had to change the code slightly, the "ClientFrmVw" wasn't declared and i'm not sure exactly why it was in there.

Also the Page.RegisterStartupScript is out of date command but it lets me run it anyways.

Code:
 Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
        Dim GdVwReview As GridView = DirectCast(FindControl("GridView1"), GridView)

        Dim index As Integer = Convert.ToInt32(e.CommandArgument)

        Dim value As String = GdVwReview.DataKeys(index).Value.ToString()
        Dim xScript As String = "<script language='javascript'>window.open('Default3.aspx?CodeID=" + value + "',name='_blank','scrollbars=0,width=800,HEIGHT=460');</script>"
        Page.RegisterStartupScript("PopUpWindowSoft", xScript)

    End Sub

I'm not sure how to setup the GridView for this?

Code:
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CodeID"
                DataSourceID="ObjectDataSource1" GridLines="None" Width="100%">
                <Columns>
                    <asp:BoundField DataField="CodeID" HeaderText="CodeID" InsertVisible="False" ReadOnly="True"
                        SortExpression="CodeID" Visible="False" />
                    <asp:BoundField DataField="CodeName" HeaderText="CodeName" SortExpression="CodeName" />
                    <asp:BoundField DataField="CodeCategory" HeaderText="CodeCategory" SortExpression="CodeCategory" />
                    <asp:BoundField DataField="CodeOwner" HeaderText="CodeOwner" SortExpression="CodeOwner" />
                    <asp:BoundField DataField="CodeStatus" HeaderText="CodeStatus" SortExpression="CodeStatus" />
                    <asp:CommandField ShowEditButton="True" />
                </Columns>
            </asp:GridView>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete"
                InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
                TypeName="DataSet1TableAdapters.tblCodesTableAdapter" UpdateMethod="Update">
                <DeleteParameters>
                    <asp:Parameter Name="Original_CodeID" Type="Int32" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CodeName" Type="String" />
                    <asp:Parameter Name="CodeDescription" Type="String" />
                    <asp:Parameter Name="CodeCategory" Type="String" />
                    <asp:Parameter Name="CodeOwner" Type="String" />
                    <asp:Parameter Name="CodeStatus" Type="String" />
                    <asp:Parameter Name="Original_CodeID" Type="Int32" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="CodeName" Type="String" />
                    <asp:Parameter Name="CodeDescription" Type="String" />
                    <asp:Parameter Name="CodeCategory" Type="String" />
                    <asp:Parameter Name="CodeOwner" Type="String" />
                    <asp:Parameter Name="CodeStatus" Type="String" />
                </InsertParameters>
            </asp:ObjectDataSource>
        </div>

Cheers :D
 
This line:

Code:
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CodeID" DataSourceID="ObjectDataSource1" GridLines="None" Width="100%">

Should be this:

Code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CodeID" OnRowCommand="GridView1_RowCommand" DataSourceID="ObjectDataSource1" GridLines="None" Width="100%">

Stelly
 
Thanks dude, got it working :)

Any idea about it saying that "Page.RegisterStartupScript" is obsolete?

It recommends using ClientScript.RegisterStartupScipt but when I use that I can an error saying ClientScript is not declared
 
Bit of a problem...

I've got paging enabled on the GridView so it's performing the PopUp when I change page (I need paging on here).

If I try go back to the first page i'm getting an error

"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"
 
Back
Top Bottom