【发布时间】:2014-12-22 13:33:26
【问题描述】:
当我尝试在 VB 中运行一些代码时出现错误,我有一些 VB 代码告诉我的 Griview 添加一个标有“插入电子邮件”的标签 在不包含电子邮件地址的任何行中的最后一列中:
我还有一些代码,一旦单击列中的标签,我想打开一个 Ajax 模态弹出框:
这是我的更新代码(仍然无法使用):
'----------------------------------------
For i As Integer = 0 To GridView1.Rows.Count - 1
If GridView1.Rows(i).Cells(9).Text = " " Then
Dim lbl As String
lbl = "Insert Email"
GridView1.Rows(i).Cells(9).Text = lbl
e.Row.Cells(9).Attributes("OnMouseOver") = "this.style.textDecoration='underline'; this.style.cursor='hand';"
e.Row.Cells(9).Attributes("OnMouseOut") = "this.style.textDecoration='none';"
e.Row.Cells(9).Attributes.Add("OnClick", "document.getElementById('" + deletePopup.ClientID + "').style.visibility= 'True'")
End If
Next
'----------------------------------------
错误是:
错误:无法获取未定义或空引用的属性“样式”
我认为是指这一行:
e.Row.Cells(9).Attributes.Add("OnClick", "document.getElementById('deletePopup').Style.Visible = True'")
这是它应该打开的模态弹出窗口的 ASPX 代码:
<div id="deletePopup" runat="server" class="modalPopup"
style="padding: 2px; width: 396px;" visible="false">
<asp:HiddenField ID="ServiceID" runat="server" />
<asp:HiddenField ID="HiddenDesc" runat="server" />
<asp:Label ID="Label4" runat="server" Text="Type in an Email:"></asp:Label>
<asp:TextBox ID="EmailTextBox1" runat="server" Height="22px" Width="370px"></asp:TextBox>
<asp:Button ID="UpdateEmailBtn" runat="server" Text="Update Email" />
<asp:Button ID="cancelButton" runat="server" Text="Cancel" />
</div>
我希望得到一些帮助。提前谢谢你...
我不太确定我输入的代码是否正确...
【问题讨论】:
-
您很可能已经检查过了。但是您确定确实存在 id 为“deletePopup”的元素吗?
-
您应该尝试
document.getElementById("deletePopup").style.display = "none",但在此之前请检查页面中是否有deletePopup元素。 -
属性区分大小写 ;)
-
然后用
deletePopup.ClientID代替deletePopup。 -
是的,它被正确引用,我只是不明白为什么它不起作用。 @ArindamNayak
标签: javascript asp.net ajax vb.net gridview