Anyname Donotcare
Anyname Donotcare

Reputation: 11403

About Popup Window in ASP.Net

I have a gridview which contains a details button as the last column.

My aspx:

<asp:GridView Width="100%" ID="gv_NotApplied" CssClass="datatable" AllowSorting="True"
    runat="server" TabIndex="2" AutoGenerateColumns="False" AllowPaging="True" GridLines="None">
    <Columns>
        <asp:TemplateField HeaderText="serial">
            <ItemTemplate>
                <asp:Label ID="lblSerial" runat="server"></asp:Label>

            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField HeaderText="name" DataField="crs_name" />
        <asp:BoundField HeaderText="lecturer" DataField="name" />
        <asp:TemplateField HeaderText="details">
            <ItemTemplate>
                <asp:ImageButton ID="Ibtn_Details" runat="server" ImageUrl="~/Images/detail.png"
                    CommandArgument='<%#((GridViewRow)Container).RowIndex%>' CommandName="Detail"
                    CausesValidation="false" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <RowStyle VerticalAlign="Top" CssClass="row" />
</asp:GridView>

What I would like to do is:

Upvotes: 8

Views: 66701

Answers (3)

Steav
Steav

Reputation: 1486

For this kind of thing I love the following construct:

<asp:UpdatePanel id="UpdatePanel1" runat="server">
  <ContentTemplate>
    <asp:Panel id="popup" visible="false" runat="server">
      popup Content
    </asp:Panel>

    <asp:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender1" TargetControlID="popup" runat="server" />
    <asp:DragPanelExtender ID="DragPanelExtender1" TargetControlID="popup" runat="server" />
  </ContentTemplate>
 </asp:UpdatePanel>
  • Like this you can set popup.visible = true; when you need the popup and have full control over its contents.
  • The Updatepanel + Ajax Control Toolkit Extender will give it the look and feel of an independant popup, though.

Upvotes: 3

Naor
Naor

Reputation: 24093

Create your desire aspx popup and add javascript event to the button. For example:

<button onclick="window.open('_blank', 'www.google.co.il', 'width=100,height=100');">asdasd</button>

You can put the event using the code behind and not direct on the aspx in order to give different url for each button.
In order to find the controls in the item tamplate read here:

http://forums.asp.net/t/998368.aspx/1?Frustated+of+FindControl+FindControl+in+GridView+s+ItemTemplate

Upvotes: 1

Samir Adel
Samir Adel

Reputation: 2499

I suggest that you open a modal pop up window like colorbox and this color box can point to show an aspx page that contain all the controls that you want. The color box will tell you how to make your button open the modal window and how to put in it the page.

Upvotes: 3

Related Questions