HTML & ASP.NET Web Forms
<div class="box-5 text-right" id="dvbtnn" runat="server">
<a href="#" id="applyanchor" class="apply-btn" data-bs-toggle="modal"
onclick="return filldata('<%#DataBinder.Eval(Container.DataItem, "ipo_prfrm")%>',
'<%#DataBinder.Eval(Container.DataItem, "priceto")%>',
'<%#DataBinder.Eval(Container.DataItem, " minord")%>',
'<%#DataBinder.Eval(Container.DataItem, " mklot")%>',
'<%#DataBinder.Eval(Container.DataItem, " symbse")%>',
'<%#DataBinder.Eval(Container.DataItem, "filename")%>','','<%#FormatFunctions.C_Format.M_FormatDate(DataBinder.Eval(Container.DataItem, " issuefrm").ToString(), "dd/MMM/yyyy")%>',
'<%#FormatFunctions.C_Format.M_FormatDate(DataBinder.Eval(Container.DataItem, " issueto").ToString(), "dd/MMM/yyyy")%>',
'<%#FormatFunctions.C_Format.M_FormatDate(DataBinder.Eval(Container.DataItem, " MTimFrm").ToString(), "hh:mm tt")%>',
'<%#FormatFunctions.C_Format.M_FormatDate(DataBinder.Eval(Container.DataItem, " MTimTo").ToString(), "hh:mm tt")%>','','',
'<%#DataBinder.Eval(Container.DataItem, " tick")%>',
'<%#DataBinder.Eval(Container.DataItem, "ExTypeNew")%>',
'<%# FormatIpoName(DataBinder.Eval(Container.DataItem, " name").ToString()) %>');"
data-bs-target="#apply">APPLY</a>
<a style="display: none;" href="companyinfo.aspx"><i class="fa fa-angle-right"></i></a>
</div>
<asp:HiddenField ID="minprice" runat="server" />
<asp:HiddenField ID="maxprice" runat="server" />
<asp:HiddenField ID="categoryhdn" runat="server" />
<asp:HiddenField ID="symbolhdn" runat="server" />
<asp:HiddenField ID="discounthdn" runat="server" />
<asp:HiddenField ID="issuefromtimehdn" runat="server" />
<asp:HiddenField ID="issuetotimehdn" runat="server" />
<asp:HiddenField ID="issuefromdatehdn" runat="server" />
<asp:HiddenField ID="issuetodatehdn" runat="server" />
<asp:HiddenField ID="ticksizehdn" runat="server" />
<asp:HiddenField ID="minqty" runat="server" />
<asp:HiddenField ID="lotsize" runat="server" />
<asp:HiddenField ID="exchanges" runat="server" />
<asp:HiddenField ID="NAME" runat="server" />
Explanation of ASP.NET Data Binding
How it Works
When the page is rendered, these data binding expressions are evaluated by ASP.NET, and the corresponding values (like prfrm, priceto, symbse, etc.) are inserted dynamically into the JavaScript function call.
The onclick event triggers a JavaScript function (filldata) and passes these dynamically bound values as arguments to the function.
JavaScript (filldata function)
function filldata(pricef, priceto, minqty, lot, symbol, logoname, category, issuefromdate, issuetodate, issuefromtime, issuetotime, discounttype, discount, ticksize, exchange, name) {
$("#symbolhdn").val(symbol);
$("#minqty").val(minqty);
$("#lotsize").val(lot);
$("#minprice").val(pricef);
$("#maxprice").val(priceto);
$("#exchanges").val(exchange);
$("# NAME").val(iponame);
$("#logodiv").attr("src", "admin/files/" + logoname);
$("#issuefromtimehdn").val(issuefromtime);
$("#issuetotimehdn").val(issuetotime);
$("#issuefromdatehdn").val(issuefromdate);
$("#issuetodatehdn").val(issuetodate);
}
Explanation of filldata Function
Purpose: The function filldata is used to dynamically populate HTML elements with values, which are passed from the server-side (ASP.NET) to the client-side (JavaScript). It allows the frontend to reflect the data bound from the backend (e.g., IPO-related details) when the user interacts with the page.
Details of What Happens Inside the filldata Function
Modal Interaction
Bootstrap Modal: The data-bs-toggle="modal" and data-bs-target="#apply" attributes indicate that this link triggers a Bootstrap modal with the id="apply". The modal is displayed when the user clicks the "APPLY" button.
The modal will likely be populated with all the data passed to the filldata function, allowing the user to see more details and potentially make a decision or take action related to the IPO.
Full Flow
Rendering Page
User Clicks "APPLY"
When the user clicks the "APPLY" button, the onclick event triggers the filldata JavaScript function.
The JavaScript function fills in various hidden fields, image sources, and other UI elements with the data that was dynamically bound from the backend.
Populate Modal
The modal (with id="apply") is shown, and the data is now available for further interaction (e.g., the user can see details like issue dates, prices, and symbol).
Key Takeaways
Data Binding (ASP.NET): The use of <%# %> syntax in ASP.NET enables dynamic insertion of data into the HTML elements. This allows backend data to be passed to the frontend dynamically.
Client-Side Interaction (JavaScript/jQuery): The filldata function takes the dynamic data and uses jQuery to update various elements on the page, such as hidden fields, image sources, and form controls, providing a seamless interactive experience.
Bootstrap Modal: The modal is triggered dynamically, and it can be populated with values passed through JavaScript, making it possible to show details to the user in an organized and interactive way.