Modal Popup in Gridview
I am about to destroy a segment of code in one of my projects, but before I do, I think it can help someone:
<asp:GridView ID="gvwProjects" runat="server" ShowHeader="false" EnableTheming="false" AutoGenerateColumns="false" OnRowCreated="gvwProjects_RowCreated" BorderWidth="0px" OnSelectedIndexChanged="gvwProjects_SelectedIndexChanged">
AutoGenerateColumns="false" OnRowCreated="gvwProjects_RowCreated" BorderWidth="0px" OnSelectedIndexChanged="gvwProjects_SelectedIndexChanged"><Columns>
<asp:TemplateField>
<asp:TemplateField><ItemTemplate> <asp:ImageButton ID="imgProject" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' ImageAlign="Left" AlternateText='<%# Eval("ImageAlternateText") %>' CommandName="Select" Style="padding-right: 15px" />
ImageAlign="Left" AlternateText='<%# Eval("ImageAlternateText") %>' CommandName="Select" Style="padding-right: 15px" /><asp:Label ID="lblProject" runat="server" Text='<%# Eval("Abstract") %>' />
<asp:Panel ID="pnlProject" runat="server" style="display:none" ScrollBars="Horizontal" CssClass="ModalPopupPanel"> <div style="float:right;">
<asp:LinkButton ID="lnkClose" runat="server">Close</asp:LinkButton> </div>
<asp:Label ID="lblDescription" runat="server" Text='<%# Eval("Description") %>' /><br /><br /> Teams Sent: <asp:Label ID="lblTeamsSent" runat="server" Text='<%# Eval("TeamsSent") %>' /><br />
Volunteers: <asp:Label ID="lblPeopleVolunteered" runat="server" Text='<%# Eval("PeopleVolunteered") %>' />
</asp:Panel> <ajax:ModalPopupExtender ID="extProject" runat="server" TargetControlID="btnTrigger" PopupControlID="pnlProject" DropShadow="true" BackgroundCssClass="ModalPopupBackground" CancelControlID="lnkClose" /><
PopupControlID="pnlProject" DropShadow="true" BackgroundCssClass="ModalPopupBackground" CancelControlID="lnkClose" /><<!-- Do not remove; triggers the modal popup --> <asp:Button ID="btnTrigger" runat="server" Style="display: none" />
</ItemTemplate></asp:TemplateField> </Columns> </asp:GridView>
The modal popup extender maps to a button that is hidden. Why do I do that? In the Selected index changed event handler, I did this:
</asp:GridView>
The modal popup extender maps to a button that is hidden. Why do I do that? In the Selected index changed event handler, I did this:
The modal popup extender maps to a button that is hidden. Why do I do that? In the Selected index changed event handler, I did this:
void gvwProjects_SelectedIndexChanged(object sender, EventArgs e) {
GridViewRow row = ((GridView)sender).SelectedRow; if (row == null) return; ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender; if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender; if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
if (row == null) return; ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender; if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
ModalPopupExtender extender = row.FindControl("extProject") as ModalPopupExtender; if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
if (extender != null) extender.Show(); }
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
}
This was a web site project for our work down in Louisiana, that I was working on for my church. Essentially, when the user clicks on an image button, it triggers the selected index changed event (through the select command name), which then triggers this code and the show method shows the modal popup, which shows details about a project. Through this, you can programmatically popup an modal window.
The CSS class that I use for the background is also defined as this:
.ModalPopupBackground
{
background-color:#162C66; opacity:.9; filter: alpha(opacity=90); }
I hope you may find use in this.
}
I hope you may find use in this.
filter: alpha(opacity=90); }
I hope you may find use in this.
}
I hope you may find use in this.
opacity:.9; filter: alpha(opacity=90); }
I hope you may find use in this.
}
I hope you may find use in this.
filter: alpha(opacity=90); }
I hope you may find use in this.
}
I hope you may find use in this.