在asp.net中,带有引导程序的对话框模式中的Gridview onclick-in会将值返回到模式父页Web表单
Gridview onclick in dialog modal with bootstrap in asp.net return values to modal father page webforms
我花了一整天的时间尝试和搜索如何在模态弹出窗口内的网格视图中单击一行,并将这些值返回到模态弹出窗口"父"上的标签/文本框中,我已经在使用javascript打开和关闭模态了。退货可以放在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
document.getElementById('<%= txtExample.ClientID %>').value = texto;
我想你忘了在上面的声明中添加.value
。
相关文章:
- 如何在模式框中显示ajax调用返回的数据
- 多次调用方法后返回相同promise的模式
- 如果返回false,如何在提交时关闭引导模式
- 如何使用lodash返回与模式匹配的属性数组
- 是否可以使find()和findOne()方法只返回模式字段
- Queryselect()在javascript模块模式中返回null
- jQuery - 用户单击模式上的“是”按钮后返回到初始屏幕
- 这是一种常见的模式吗?(返回数据而不是返回承诺)
- JavaScript 正则表达式,返回模式之前和之后的所有内容
- JavaScript 中的无意义的返回模式
- 是否可以使控制器返回模式窗口的数据?MVC5 ASP.NET
- 原型揭示模式和'这'嵌套函数或返回对象中
- 通过 JS 模块模式返回 ajax 响应
- 模式返回var &&var = = = & # 39;一些# 39;在javascript
- 关闭bootstrap模式返回按钮
- 为什么组合构造函数/原型模式返回对象类型
- javascript模块模式返回对象引用
- JavaScript模块模式-返回的对象===模块||facade
- Javascript链接模式返回该对象的等价项,而不是返回this
- Jquery点击打开模式返回“;undefined不是函数”;