0

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?

2

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

9 Comments

the linkButton is calling the getEmailContacts already if you take a look at the code, its the #emailAddresss i need to get to open the div in the fancy box
the standard <a href="..."> works to call the fancybox, the linkbutton calls the codebehind, but what i need is to have the linkbutton to call the method, then call the javascript to open the fancybox
This answer is what you looking for then. It's the JQuery that's your problem. Instead of getEmailContacts(); use $('#getEmailContacts').click();
can you adjust your answer to show me how you mean then please
Sorry I mean't $('#emailAddresses').click(), I've updated the answer.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.