<div> <style type="text/css"> .black_overlay{ display:none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color:black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .popup { width:439px; height:365px; position:fixed; top:50%; left:36%; right:10%; bottom:50%; margin:-50px 0 0 -100px; /* [-(height/2)px 0 0 -(width/2)px] */ z-index:2222; background-color:#FFFFFF; color:White; visibility:hidden; } .style1 { height: 15px; } .style2 { width: 40%; height: 97px; } .style3 { height: 97px; } </style> <script type="text/javascript"> function show_popup(pric) { //calling from code behind... var popup = document.getElementById('<%=popup.ClientID %>'); popup.style.visibility = 'visible'; document.getElementById('Div1').style.display = 'block'; document.getElementById('<%=lblnotice.ClientID %>').innerHTML = pric; return false; } function hidePopup() { var popup = document.getElementById('<%=popup.ClientID %>'); popup.style.visibility = 'hidden'; document.getElementById('Div1').style.display = 'none'; return false; } </script> <asp:DataList ID="dl" runat="server" OnItemDataBound="item_bound"> <itemtemplate> <asp:Label ID="ru" Text='<%# DataBinder.Eval(Container.DataItem,"name")%>' runat="server"> <asp:LinkButton ID="lnkviewcart" CausesValidation="true" Enabled="true" CommandName="imgclicked" Visible="false" runat="server" Text="See Price in Cart" > </itemtemplate> <div id="Div1" class="black_overlay"> </div> <div id="popup" align="center" class="popup" runat="server"> <table width="100%" style="removed50%;"> <tr><td><hr style=" height:10px; background-color:#ff0000;" /></td></tr> <tr align="center" style=" width:90%;"><td align="left" style=" color:#565454;"><table width="100%"><tr><td style="font-family:Verdana; font-size:16px; color:#565454; ">Your Price @ Lee's Tools</td> <td><asp:Label ID="lblnotice" runat="server" ForeColor="#ff0000" Font-Names="Verdana" Font-Size="15px" Font-Bold="true"></td></tr></table></td></tr> <tr><td><hr style=" height:4px; background-color:#ff0000;" /></td></tr> <tr><td></td></tr> <tr> <td align="right"> <table width="100%"> <tr><td align="left"><asp:ImageButton ID="imgclose" runat="server" ImageUrl="../Image/closebut.png" OnClientClick="return hidePopup();" /> </td> <td align="right"><asp:ImageButton ID="imgpopadd" runat="server" ImageUrl="../Image/Addtocart/cart_button.png" OnClick="addtocart_clicked_popup" /> </td> </tr> </table> </td></tr> <tr><td></td></tr> </table> </div>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; namespace popjavascript { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Bind(); } } public void Bind() { DataTable dt = new DataTable("new"); dt.Columns.Add("name"); dt.Columns.Add("price"); dt.Rows.Add("christh", "100.00"); // dt.Rows.Add("100.00","price"); dl.DataSource = dt; dl.DataBind(); } protected void addtocart_clicked_popup(object sender, ImageClickEventArgs e) { Response.Write("hello"); } protected void item_bound(object sender, DataListItemEventArgs e) { LinkButton linkmp = (LinkButton)e.Item.FindControl("lnkviewcart"); Label lblprice = (Label)e.Item.FindControl("ru"); linkmp.Visible = true; linkmp.OnClientClick = "retun show_popup(' " + lblprice.ToString().Trim() + "'); retun false;"; } } }
christhuxavier wrote:I am sorry for not clear... I mean my Javascript function is not invoked when I click on click button "See Price in Cart". [text modified to fix a number of mistakes — SA]
$(document).ready(function() { $("#lnkviewcart").click(function() { // where id="lnkviewcart" for // do something on click, can use $(this), which is a jQuerty wrapper of the clicked element }); });
id
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)