Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can use hidden field instead of viewstate, if you really want to retain some value at code behind. You can access hidden field at client side as well as in code behind too. </p> <pre><code> &lt;asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClientClick="return CheckType('save');"&gt;Click Here To Add New Address&lt;/asp:LinkButton&gt; &lt;asp:HiddenField ID="hdf_type" runat="server" /&gt; </code></pre> <p><strong>Javascript code</strong></p> <pre><code>function CheckType(type) { document.getElementById("hdf_type").value = type; return false; } </code></pre> <p>Access value in code behind when clicked on save button, and perform your action save or update according to value in hidden field.</p> <pre><code>hdf_type.Value.ToString(); </code></pre> <p><strong>MORE HELP FOR YOU</strong></p> <p><strong>HTML FILE SHOULD LOOK LIKE THIS</strong></p> <p>below i'm posting the whole code which is working fine for me.</p> <pre><code>&lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript"&gt; function CheckType(type) { document.getElementById("hdf_type").value = type; alert(document.getElementById("hdf_type").value); return false; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;div&gt; &lt;asp:LinkButton ID="lnkAddNewAddress" runat="server" OnClientClick="return CheckType('save');"&gt;Click Here To Add New Address&lt;/asp:LinkButton&gt; &lt;asp:Button ID="btn" runat="server" OnClientClick="return CheckType('edit');" Text="Click Here To Add New Address" /&gt; &lt;asp:ModalPopupExtender ID="lnkAddNewAddress_ModalPopupExtender" runat="server" BackgroundCssClass="modalBackground" DynamicServicePath="" Enabled="True" PopupControlID="pnlMyAddressBook" TargetControlID="lnkAddNewAddress" ViewStateMode="Enabled"&gt; &lt;/asp:ModalPopupExtender&gt; &lt;div id="pnlMyAddressBook" style="height: 100px; width: 100px; display: none; background-color: Gray"&gt; &lt;asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /&gt;&lt;br /&gt; &lt;/div&gt; &lt;asp:HiddenField ID="hdf_type" runat="server" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p></p> <p>getting value at code behind:</p> <p><img src="https://i.stack.imgur.com/WLmqZ.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload