【发布时间】:2015-12-25 05:45:41
【问题描述】:
我整天都在尝试和搜索如何在模式弹出窗口内的网格视图中连续单击并将这些值返回到模式弹出窗口的“父亲”上的标签/文本框,我已经在使用 javascript打开和关闭模式。 return 可以放在 closeModal() 中。我只需要一个例子,我查看了很多论坛和页面,但没有找到这样的。谢谢你的帮助
这是 ASP.NET 代码
<script>
function openModal() {
$('#myModal').modal('show')
};
function closeModal() {
console.log("Sai")
$('#myModal').modal('hide')
document.getElementById('<%= lblTeste.ClientID %>').innerHTML = 'Your new value';
console.log("valor mudado")
};
function sendTex(texto) {
document.getElementById('<%= txtExample.ClientID %>') = texto;
}
</script>
<asp:Label id="lblSelected" runat="server"></asp:Label>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" runat="server">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<asp:TextBox ID="txtBusca" runat="server"></asp:TextBox>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="gvBusca" OnRowDataBound="OnRowDataBound"
OnSelectedIndexChanged="OnSelectedIndexChanged" DataKeyNames="id"
runat="server" GridLines="Horizontal"
BorderStyle="None" CssClass="table table-striped table-hover ">
</asp:GridView>
<asp:Button ID="btnBusca" runat="server" Text="Button" />
<asp:Label id="lblValor" runat="server" Text=""></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="closeModal()">Close</button>
</div>
</div>
</div>
</div>
这是后面的代码:
Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvBusca.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onclick") = Page.ClientScript.GetPostBackClientHyperlink(gvBusca, "Select$" & e.Row.RowIndex)
e.Row.Attributes("style") = "cursor:pointer"
End If
End Sub
Protected Sub OnSelectedIndexChanged(sender As Object, e As EventArgs) Handles gvBusca.SelectedIndexChanged
Dim index As Integer = gvBusca.SelectedRow.RowIndex
Dim name As String = gvBusca.SelectedRow.Cells(0).Text
Dim country As String = gvBusca.SelectedRow.Cells(1).Text
Dim message As String = "Row Index: " & index & "\nName: " & name + "\nCountry: " & country
ClientScript.RegisterStartupScript(Page.GetType(), "Desc", "sendText('" + name + "');", True)
End Sub
【问题讨论】:
标签: javascript jquery asp.net vb.net twitter-bootstrap