title: pass client id from within the gridview to javascript function
body: <p>I have a gridview that get binds dynamically. i have a linkbutton attached with every row that opens a modal popup window which I need to show some text which is in a hidden field in gridview. </p>
  
  <p>I need to call a javascript function that sets the value of the label in the popup panel with the text of the hidden field. The problem is that the value is always blank when the popup is displayed.</p>
  
  <p>Java script code is - </p>
  
  <pre><code>  function SetNotesonModal(note)
     {
          //debugger;
          var notes = document.getElementById(note.id).innerHTML;
          document.getElementById('ctl00_ContentPlaceHolder1_popupLblNote').value = notes;
     }
  </code></pre>
  
  <p>Code for calling the function is - </p>
  
  <pre><code>lnkViewNotes.Attributes.Add("OnClick", "return SetNotesonModal(" + e.Row.FindControl("lblNote").ClientID + ");");
  </code></pre>
  
  <p>The controls in gridview are as - </p>
  
  <pre><code>&lt;ItemTemplate&gt;
       &lt;asp:Label ID="lblNote" runat="server" Text='&lt;%# Bind("notes") %&gt;'&gt;&lt;/asp:Label&gt;
       &lt;asp:LinkButton ID="lnkViewNotes" runat="server"&gt;View&lt;/asp:LinkButton&gt;
       &lt;asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="lnkViewNotes" PopupControlID="Panel2" CancelControlID="popupBtnClose"&gt;
       &lt;/asp:ModalPopupExtender&gt;
  &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p>And the panel for popup is - </p>
  
  <pre><code>&lt;asp:Panel ID="Panel2" runat="server" ScrollBars="Auto" align="center" Style="display: none"
      CssClass="modalPopup"&gt;
      &lt;table class="border" style="text-align: left; height: 100%" width="100%"&gt;
          &lt;tr align="left" style="background-color: #5D7B9D; color: White"&gt;
              &lt;th&gt;
                  Notes
              &lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="popupLblNote" runat="server"&gt;&lt;/asp:Label&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;asp:Button ID="popupBtnClose" runat="server" Text="Close" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>The javascript function is being called perfectly and its is also setting value of the label in popup panel correctly but not sure why the popup comes blank every time.</p>
  
  <p>Any kind of help is welcome. </p>
  
  <p>Thanks</p>