Reputation: 3261
I am trying to get a fancybox to open with a div and a gridview once the gridview has been populated with data.
I can either get the fancybox to open with nothing by calling the fancybox directly, or i can populate the girdview without the showing the fancybox.
this is the code i have that just populates the girdview at the moment as this is where I need to go from.
Any and all help appreicated.
The method
Public Sub GetEmailContacts()
Session("RoleCode") = 27
Dim dt As DataTable
Dim dtToBind As DataTable = New DataTable()
dtToBind.Columns.Add("Contact Type", Type.GetType("System.String"))
dtToBind.Columns.Add("First Name", Type.GetType("System.String"))
dtToBind.Columns.Add("Last Name", Type.GetType("System.String"))
dtToBind.Columns.Add("Email Address", Type.GetType("System.String"))
dt = GetValues()
For Each dr As DataRow In dt.Rows
dtToBind.Rows.Add(dr(0).ToString(), dr(6).ToString(), dr(7).ToString(), dr(9).ToString())
Next
For Each dr As DataRow In dtToBind.Rows
Dim toButtonField = New ButtonField() With {
.ButtonType = ButtonType.Button,
.Text = "To: ",
.CommandName = "DoSomething"
}
Dim ccbuttonField = New ButtonField() With {
.ButtonType = ButtonType.Button,
.Text = "Cc: ",
.CommandName = "DoSomething"
}
gvContactList.Columns.Add(toButtonField)
gvContactList.Columns.Add(ccbuttonField)
Exit For
Next
gvContactList.DataSource = dtToBind
gvContactList.DataBind()
bttnTo.Attributes.Add("OnClientClick", "#emailAddress")
End Sub
The LinkButton :
<asp:LinkButton runat="server" cssclass="fancybox" ID="bttnTo" OnClick="getEmailContacts"><span style='font-size: 20px; color: darkgreen'><i id="toEmail" class="fa fa-users sameRow margin10"></i></span></asp:LinkButton>
this is whats in the JS File too
$(document).ready(function () {
$(".fancybox").fancybox({
parent: "form:first" // jQuery selector
});
});
a standard link
<a href="#emailAddresses" class="fancybox"><span style='font-size: 20px; color: darkgreen'><i id="toEmail" class="fa fa-users sameRow margin10"></i></span></a>
how would be best to call this function?
Upvotes: 0
Views: 145
Reputation: 332
Here update your javascript
$(document).ready(function () {
fancybox = $(".fancybox").fancybox({
parent: "form:first" // jQuery selector
});
if (gridLoaded) {
fancybox.click();
}
});
You must gridLoaded
to false on first page load, then when you are done loading the grid set the gridLoaded
to true.
Upvotes: 1