0
我有一個gridview動態綁定。我有一個鏈接按鈕附加每一行,打開一個模式彈出窗口,我需要顯示一些隱藏在gridview中的字段中的文本。從GridView中傳遞客戶端id到javascript函數
我需要調用一個javascript函數,該函數使用隱藏字段的文本在彈出面板中設置標籤的值。問題是顯示彈出窗口時,該值始終爲空。
的Java腳本代碼 -
function SetNotesonModal(note)
{
//debugger;
var notes = document.getElementById(note.id).innerHTML;
document.getElementById('ctl00_ContentPlaceHolder1_popupLblNote').value = notes;
}
代碼調用函數是 -
lnkViewNotes.Attributes.Add("OnClick", "return SetNotesonModal(" + e.Row.FindControl("lblNote").ClientID + ");");
中的GridView控件是 -
<ItemTemplate>
<asp:Label ID="lblNote" runat="server" Text='<%# Bind("notes") %>'></asp:Label>
<asp:LinkButton ID="lnkViewNotes" runat="server">View</asp:LinkButton>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="lnkViewNotes" PopupControlID="Panel2" CancelControlID="popupBtnClose">
</asp:ModalPopupExtender>
</ItemTemplate>
而對於彈出的面板 -
<asp:Panel ID="Panel2" runat="server" ScrollBars="Auto" align="center" Style="display: none"
CssClass="modalPopup">
<table class="border" style="text-align: left; height: 100%" width="100%">
<tr align="left" style="background-color: #5D7B9D; color: White">
<th>
Notes
</th>
</tr>
<tr>
<td>
<asp:Label ID="popupLblNote" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button ID="popupBtnClose" runat="server" Text="Close" />
</td>
</tr>
</table>
</asp:Panel>
JavaScript函數被完美調用,它也正確設置彈出窗口中的標籤值,但不知道爲什麼彈出窗口每次都是空白的。
歡迎任何形式的幫助。
感謝
使用.NET,您可以使用客戶端ID來獲得在客戶端以HTML格式呈現的客戶端ID。你已經使用過它,一切都很好。我建議你檢查一下你的Javascript不工作。 也許你可以發佈已經生成的HTML。或者您可以使用Firebug檢查它,看看正在產生什麼。 – Rajesh 2012-08-08 10:15:48
我的javascript工作正常我調試它的設置的值,但不知道爲什麼它不保留該值。它是否與鏈接按鈕有關,因爲它可能會回傳並導致值丟失 – akhil 2012-08-08 10:18:54