Send Parameter to Javascript function from ASP Net Button in ListView RRS feed

  • Question

  • User1228272764 posted


    I have condition, wich every button in Listview should be produce dynamicaly depends number of ListView Rows. The button shold display popup when clicked and at the same time sending parameter to Javascript function. This is how my code goes : 

    This is my Form 

        <form id="form1" runat="server">
    <%--    <div>
            <asp:Button ID="BtnPop" runat="server" Text="Pop Me Up" OnClientClick="showModalPopUp()" />
        <div id = "divBackground" style="; z-index: 999; height: 100%; width: 100%; top: 0; left:0; background-color: Black; filter: alpha(opacity=60); opacity: 0.6; -moz-opacity: 0.8;display:none">
    	        <asp:SqlDataSource ID="SqlDataIzin" runat="server"
    	            ConnectionString="<%$ ConnectionStrings:MyConnCloudDnet2 %>"
    			    SelectCommand="SELECT TOP 3 * FROM Data_izin_header;"
    			    ProviderName="<%$ ConnectionStrings:MyConnCloudDnet2.ProviderName %>">
                <asp:ListView ID="ListView1" DataSourceID="SqlDataIzin"  runat="server">
                            <asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
                            <td><asp:Button ID="BtnPop" runat="server" Text="Pop Me Up" OnClientClick="showModalPopUp()" /></td>    

    This is my script on Head tag of my page

    <script type = "text/javascript">
        var popUpObj;
        function showModalPopUp(id)
        "toolbar=no," +
        "scrollbars=no," +
        "location=no," +
        "statusbar=no," +
        "menubar=no," +
        "resizable=0," +
        "width=500," +
        "height=500," +
        "left = 90," +
    <script type = "text/javascript">
        function LoadModalDiv()
            var bcgDiv = document.getElementById("divBackground");
    <script type = "text/javascript">
         function HideModalDiv()
            var bcgDiv = document.getElementById("divBackground");

    the main problem is, how could we pass parameter from button click event and use it as input for URLString ? 


    i want to send related eval value as a parameter for javascript function

    this should be my main problem :


    when i tried this, it throw undefined value :


    do you have any suggestions?

    Tuesday, April 2, 2019 3:09 AM


  • User1228272764 posted

    done by this code : 

    <td><asp:Button ID="BtnPop" runat="server" Text="Pop Me Up" OnClientClick='<%# Eval("IZIN_NAMA", "showModalPopUp(\"{0}\")")%>' /></td>  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 2, 2019 4:07 AM