Thanks guys, you all are life savers...
I thought I'd share some more findings related to this topic.
Scenario: Checkbox and Modalpopupextender within a Gridview
For example, you have a gridview in which you'd like to hadve the Modal Pop up come out while on the onclick event on an item template with a checkbox defined within it.
Same concept, the only things I'd like to add are:
- You add an attribute to the checkbox via the gridview1_RowDataBound event... passes "this" and the btn_open.ClientID such as (pay special attention to the single quote and double quotes within the cbx_Checkbox1.Attributes.Add line):
Protected Sub gv_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim btn_Open As WebControl = e.Row.FindControl("buttonOpen")
Dim cbx_Checkbox1 As WebControl = e.Row.FindControl("CheckBox1")
Dim repStr As String = btn_Open.ClientID
cbx_Checkbox1.Attributes.Add("onclick", "popup(this,'" + repStr + "')")
End If
End Sub
The Aspx file has the following under the TemplateField within the gridview "gv":
<ItemTemplate>
<asp:Button ID="buttonOpen" runat="server" Style="display: none" />
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:Panel ID="Panel11" runat="server" Style="display: none; padding: 10px; border: 1px;
border-style: solid;" BackColor="#FFFFFF" Width="400px">
<div id="DragPanel1" runat="server" class="PopUpHeader">
<table width="100%">
<tr>
<td style="width: 100%">
<asp:Label ID="HeaderLabel1" runat="server" Text="Choose Documents:" />
</table>
</div>
<asp:Button ID="butdone" runat="server" Text="done" />
</asp:Panel>
<atk:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="buttonOpen"
PopupControlID="Panel11" OkControlID="closeBtn" BackgroundCssClass="modalBackground"
DropShadow="true" PopupDragHandleControlID="DragPanel1" OnCancelScript="butdone" />
</ItemTemplate>
The javascript function didnt change much, if any:
<script type="text/javascript" language="javascript">
function popup(checkbox,buttonId) {
if (checkbox.checked)
$get(buttonId).click();
return true;
}