Click here to Skip to main content
15,921,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working with e-commerce website and i stuck to local storage part.
am using local storage to store product name and id,which is selected by client.
and the problem is my label defined are not storing product name and id as its of input type.
please help

What I have tried:

ASP.NET
<h4>
                            <input name="lblpname" id="lblpname" type="text" /></h4>
                        <input name="lblid" id="lblid" type="text" /><%--<input name="lblid" id="lblid" type="text" />--%>
                     <%--   <h4>
                            <asp:Label ID="pname" name="lblid" runat="server"></h4>
                        <asp:Label ID="id" name="lblid" runat="server">--%>

and code is
C#
int Prd = Convert.ToInt32(Session["Product_Id"]);
            var single1 = (from PD in drop.PRODUCT_DBM
                           join PS in drop.Prod_Size on PD.Product_Id equals PS.product_id
                           join SM in drop.Stock_Master on PD.Product_Id equals SM.Prod_Id
                           where PD.Product_Id == Prd 
                           select new { PS.Size, PD.Model_Name, PD.Model_color,SM.MRP, PD.Product_Detail, PD.Product_Name, PD.Product_type }).ToList().FirstOrDefault();
            var text1 = Request["lblpname"];
            text1 = single1.Product_Name;
            //pname.Text = Request.Form[hfName.UniqueID];
            lbldtl.Text = single1.Product_Detail;
            lblmodelname.Text = single1.Model_Name;
            lblprice.Text = single1.MRP.ToString();
            lbltype.Text = single1.Product_type;
            lblcolor.Text = single1.Model_color;
            ddlsize.SelectedValue = single1.Size;
            var text2 = Request["lblid"];
            text2 = (Prd).ToString();
            id.Text = (Prd).ToString();
            pname.Text = single1.Product_Name;
Posted
Updated 24-Apr-16 21:04pm
v2
Comments
F-ES Sitecore 22-Apr-16 6:58am    
If you want to show text on the screen use asp:Literal, if you want to put data on the page that isn't seen but included in a postback then use asp:HiddenField
ZurdoDev 22-Apr-16 7:11am    
No where do you have localStorage referenced so I do not understand what you are asking.
Member 11936990 25-Apr-16 1:55am    
<script type="text/javascript">
function fnSaveData() {

window.localStorage.setItem("CustName", document.getElementById('txtCustomer'));
window.localStorage.setItem("CustAddr", document.getElementById('id').value);
}

function fnGetData() {
//alert(window.localStorage.getItem$('#txt_name').val()("CustName"));
alert(window.localStorage.getItem("CustAddr"));
alert("Hello" + window.localStorage.getItem("CustName"));
}

function fnClearData() {
window.localStorage.clear();
}
</script>
ZurdoDev 25-Apr-16 7:04am    
OK, now what is the problem? What is the question? LocalStorage is very easy to use.
Member 11936990 26-Apr-16 1:10am    
the problem is i have some values comming from database to one label. and
i wanted that label to be printed in local storage. in the place of txtCustomer i want lblproductname. and thts not possible as i tried.

Try this...


ASP.NET
<script type="text/javascript">
        $(document).ready(function () {
            $('#btnGet').click(function () {
                window.localStorage.setItem("CustName", $('#lbl').html());
            })
            $('#BtnSet').click(function () {
                alert(window.localStorage.getItem("CustName"));


            })
        });
    </script>

<div style="padding-removed 100px">
            <asp:Label ID="lbl" runat="server" Text="My Name">
            <br />
            <asp:Button ID="btnGet" runat="server" Text="Get Value" />
            <asp:Button ID="BtnSet" runat="server" Text="Set Value" />
        </div>
 
Share this answer
 
v2
try this

JavaScript
function fnSaveData() {
           var customer = document.getElementById('<%= txtCustomer.ClientID %>').value;
           alert (customer); // make sure you are getting the vlaue
           window.localStorage.setItem("CustName",customer );
           var id = document.getElementById('id').value;
           alert(id);// make sure you are getting the vlaue
           window.localStorage.setItem("CustAddr", id);
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900