如何将文本传递给jquery中的代码,在模式弹出窗口中打开gridview [英] How to pass text to code behind in jquery that opens a gridview in modal pop up

查看:47
本文介绍了如何将文本传递给jquery中的代码,在模式弹出窗口中打开gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在网页表单中有几个按钮,执行下面的jquery。

它打开模式弹出,文本附加到标题。 Text是button.Text,它是服务器端功能的参数。



 函数 getBinDets(bin)
{
debugger ;
var url = ' DisplayGrid.aspx? param =' + encodeURIComponent(bin)
var frame = $(' < iframe />')。css(' border'' 0')。attr({
' src':url,
' width'' 100%'
' height'' 100%'

});
$( #modalbinDets
.clear()。append( frame)
.dialog({
title: Bin Details: + bin,
dialogClass:' dialog_style1'
autoOpen: true
modal: true
height: 300
宽度: 600
open: function ( event,ui){
$(' #modalbinDets')。css(' 溢出'' hidden');
},
按钮:{
关闭:功能(){
$()。对话框( close

}
}
})。prev( 。ui-dialog-titlebar).css( background lightblue);
}







现在,我想在模态弹出窗口中绑定Gridview < br $>


服务器端方法:

 受保护  Sub  Page_Load( ByVal  sender  As  对象 ByVal  e  As  System.EventArgs )句柄 。加载
如果 Page.IsPostBack 然后
BinItems()
结束 如果
结束 Sub
公共 Sub BinItems( ByVal bin As 字符串
Dim ds 作为 DataSet
Dim 数据作为 列表( 字符串
尝试

ds = db.displayAnalysis( 14 ,bin)

GridView1.DataSource = ds.Tables( 0
GridView1.DataBind()
Catch ex As 例外

结束 尝试

结束 Sub





我首先在页面加载中绑定一个虚拟行。

我的网格如下所示

 <   div     id   =  modalbinDets   >  
< asp:GridView ID = GridView1 runat = server AllowPaging = true < span class =code-attribute> AutoGenerateColumns = false >
< >
< asp:BoundField ItemStyle-Width = 150px DataField = baitem HeaderText < span class =code-keyword> = 项目 / >
< asp:BoundField ItemStyle-Width = 150px DataField = baqoh HeaderText = 现有 < span class =code-attribute> / >
< asp:BoundF ield ItemStyle-Width = 150px DataField = baqcm HeaderText = 已提交 / >
< ; asp:BoundField ItemStyle-Width = 150px < span class =code-attribute> DataField = available HeaderText = 可用 / >
< asp:BoundField ItemStyle-Width = 150px DataField = onhold < span class =code-attribute> HeaderText = 暂停 / >
< asp:BoundField ItemStyle-Width = 150px DataField = icdsc1 HeaderText = icdsc1 / >
< asp:BoundField ItemStyle-Width < span class =code-keyword> = 150px DataField = icdsc2 HeaderText = icdsc2 / >
< /列 >
< / asp:GridView >
< / div >





我尝试了什么:



到目前为止,我已经尝试了模态弹出,获得单击按钮的文本和我的数据集背后的代码已准备就绪。



我不知道如何将文本传递给代码隐藏函数(如下所示)。并在结果弹出窗口中绑定结果。



有人可以帮我这个吗?

解决方案

< blockquote>(' < iframe />')。css(' border'' 0')。attr({
' src':url,
' width'' 100%'
' height'' 100%'

});

#modalbinDets
.clear()。append(frame)
.dialog({
title: Bin Details : + bin,
dialogClass:' dialog_style1'
autoOpen: true
modal: true
height: 300
宽度: 600
open: function (event,ui){


' # modalbinDets')。css(' overflow'' hidden');
},
按钮:{
关闭:功能(){


So I have few buttons in a web form where, the below jquery is executed.
It opens the modal pop up with the Text appended to Title. And the Text is button.Text which is a parameter to server side function.

function getBinDets(bin)
        {
            debugger;
            var url = 'DisplayGrid.aspx?param=' + encodeURIComponent(bin)
            var frame = $('<iframe/>').css('border', '0').attr({
                'src':url,
                'width': '100%',
                'height':'100%'

            });
            $("#modalbinDets")
                .clear().append(frame)
                .dialog({
                        title: "Bin Details: " + bin,
                        dialogClass: 'dialog_style1',
                        autoOpen: true,
                        modal: true,
                        height: 300,
                        width: 600,
                        open: function (event, ui) {
                            $('#modalbinDets').css('overflow', 'hidden');
                        },
                        buttons: {
                            Close: function () {
                                $(this).dialog("close")

                            }
                        }
                    }).prev(".ui-dialog-titlebar").css("background", "lightblue");
        }




Now, I want to bind the Gridview in the modal pop up

server side method :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            BinItems()
        End If
    End Sub
    Public Sub BinItems(ByVal bin As String)
        Dim ds As New DataSet
        Dim data As New List(Of String)
        Try

            ds = db.displayAnalysis("14", bin)

            GridView1.DataSource = ds.Tables(0)
            GridView1.DataBind()
        Catch ex As Exception

        End Try

    End Sub



I am binding a dummy row in page load first.
And my grid is like below

<div id="modalbinDets" >
           <asp:GridView ID="GridView1" runat="server" AllowPaging="true" AutoGenerateColumns="false">
               <Columns>
                   <asp:BoundField ItemStyle-Width="150px" DataField="baitem" HeaderText="Item" />
                   <asp:BoundField ItemStyle-Width="150px" DataField="baqoh" HeaderText="On Hand" />
                   <asp:BoundField ItemStyle-Width="150px" DataField="baqcm" HeaderText="Committed" />
                   <asp:BoundField ItemStyle-Width="150px" DataField="available" HeaderText="Available" />
                   <asp:BoundField ItemStyle-Width="150px" DataField="onhold" HeaderText="On Hold" />
                   <asp:BoundField ItemStyle-Width="150px" DataField="icdsc1" HeaderText="icdsc1" />
                   <asp:BoundField ItemStyle-Width="150px" DataField="icdsc2" HeaderText="icdsc2" />
               </Columns>
           </asp:GridView>
       </div>



What I have tried:

So far, I have tried the modal pop, getting the Text of clicked button and my code behind dataset with results are ready.

I do not know how to pass the text to code behind function(as below). And bind the results in Gridview on modal pop up.

Can someone please help me with this?

解决方案

('<iframe/>').css('border', '0').attr({ 'src':url, 'width': '100%', 'height':'100%' });


("#modalbinDets") .clear().append(frame) .dialog({ title: "Bin Details: " + bin, dialogClass: 'dialog_style1', autoOpen: true, modal: true, height: 300, width: 600, open: function (event, ui) {


('#modalbinDets').css('overflow', 'hidden'); }, buttons: { Close: function () {


这篇关于如何将文本传递给jquery中的代码,在模式弹出窗口中打开gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆