access javascript variable in page load event c# -
i setting session variable in page1.aspx
inside document.ready
sessionstorage.setitem('prepayamt', 'some value stored');
now want value in page2.aspx
page load event
protected void page_load(object sender, eventargs e) { // value here }
i have declared script section in page2.aspx
able value
<script type="text/javascript"> $(document).ready(function () { var pre_pay = sessionstorage.getitem('prepayamt'); alert(pre_pay); }); </script>
i have got 1 hidden variable in page2.aspx
as
<asp:hiddenfield runat="server" id="hdnprepayamt" />
you correct try , set hidden value gets posted back, if use sever-side asp.net hiddenfield
(i.e. asp:hiddenfield
) need specify clientid="hdnprepayamt"
setting , not id=
e.g.
<asp:hiddenfield runat="server" clientid="hdnprepayamt" />
as
<asp:hiddenfield runat="server" id="hdnprepayamt" />
will generate own client-side id field.
if view page source in browser see going on
Comments
Post a Comment