0

This javascript works to a point because it will open popups as required, but they are empty! What is the syntax to pass in the two missing values for the function? The two values need to be taken from the gridview (lblEVENT_DATE & the BoundField with a DataField of DETAILS). As you will see the function opens a modal popup and is called by an input button from the gridview. The third required value in the function is hard coded.

    function OpenPopup(datetime, text, mode) {
        if (mode == 'track') {   
            $('#lblDateTime').text(datetime);
            $('#lblTrackingNotes').text(text);
            $("#divTrackingNotes").dialog({ title: "Tracking Notes", width: 700, modal: true, });
        }
        else {
            $('#lblRCAComments').text(text);
            $("#divRCAComments").dialog({ title: "Comments", width: 700, modal: true, });
        }
    }


<asp:GridView ID="GridRootCause" ClientIDMode="Static" CssClass="dataTable fullWidth spaceAfter2" runat="server" AutoGenerateColumns="False" DataKeyNames="ROOT_CAUSE_IDENTIFIER,RECORD_IDENTIFIER">
<Columns>
    <asp:BoundField DataField="RECORD_IDENTIFIER" ItemStyle-CssClass="hiddenColumn" HeaderStyle-CssClass="hiddenColumn" />      
    <asp:TemplateField HeaderText="Event Date">
        <ItemTemplate>
            <asp:Label ID="lblEVENT_DATE" runat="server" Text='<%# CDate(Eval("EVENT_DATE")).ToString("ddd") & " " & Eval("EVENT_DATE")%>' />
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Details">
        <ItemTemplate>
            <asp:Label Visible="false" Wrap="true" ID="lblDetails" runat="server" />
            <input type="button" class="innerButton buttonBlue" id="btnTrackingNotes" onclick="javascript: OpenPopup('','','track');" Visible="false" runat="server" value="Tracking Notes" /> 
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Comments" HeaderStyle-CssClass="width150">                                
        <ItemTemplate> 
            <input type="button" class="innerButton buttonBlue" id="btnComments" onclick="javascript: OpenPopup('','','comm');" Visible="false" runat="server" value="Comments" />                                  
        </ItemTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>

1 Answer 1

2

If the data fields are EVENT_DATE and DETAILS, you can set the onclick event handler this way:

onclick='<%# string.Format("OpenPopup({0}{1:ddd}{0}, {0}{2}{0}, {0}track{0});", (char)39, Eval("EVENT_DATE"), Eval("DETAILS")) %>'

One of the tricky parts of this code is inserting the single quotes inside the format string while avoiding conflicts with the outer quotes. This is why I use (char)39 for C# or chr(39) for VB.NET.

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

Comments

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.