在弹出窗口和主页之间传递值 [英] Pass values between popup and home page

查看:77
本文介绍了在弹出窗口和主页之间传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主页中的控件:文本框,按钮
弹出窗口中的控件:Gridview

到目前为止我要实现和使用的内容:
1.在文本框中输入文本,然后单击按钮.

Controls in the Home page: TextBox, Button
Controls in Pop up: Gridview

What I want to achieve and used so far:
1. Enter text in the textbox and click on the button.

protected void btnLookUp_Click(object sender, EventArgs e)
{
    string sScript = "<script>window.open('a.aspx?textbox=" + TextBox1.Text.ToString() + "','cal','left=10,top=10 resizable= yes scrollbars=yes') </script>";
    RegisterClientScriptBlock("anything", sScript);
}



2.在按钮"上单击并打开弹出窗口,并触发弹出页面的页面加载事件.
弹出页面中的Gridview控件.



2. On Button-Click the pop-up opens and on-page load event of the popup page gets triggered.
Gridview control in pop-up page.

<asp:GridView ID="GridView1" runat="server" Font-Size="10px"

    onselectedindexchanged="GridView1_SelectedIndexChanged">
    <Columns>
        <asp:CommandField SelectText="[...]" ShowSelectButton="True" />
    </Columns>
    <AlternatingRowStyle Wrap="False" />
</asp:GridView>



3.在单击网格视图中相应条目的按钮时,我要将选定的列值传递回主页中的TextBox控件.



3. On clicking the button for the corresponding entry in the gridview I want to pass selected column values back to the TextBox control in the home page.

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    string strScript = "<script>window.opener.document.forms(0)."+ control.Value.ToString() +".value = '";
    //strScript += GridView1.SelectedIndex.ToString();
    strScript += "Amresh';self.close()";
    strScript += "</" + "script>";
    RegisterClientScriptBlock("anything", strScript);
}


上面的代码给我错误'';缺少'',因为列值以整数值开头.

如何将值从弹出页面传输回首页中的文本框?
还是可以使用其他方法来实现它?


The above code gives me error ''; missing'' as the the column values starts with an integer value.

How do I transfer values back to the textbox in the home from the popup page?
Or can I achieve it using some other method?

推荐答案

该错误非常具有描述性.你失踪了;在下一行

The error is very descriptive. You are missing ; on the following line

strScript += "Amresh'';self.close()";


看看这篇文章:父页面的部分更新在子窗口关闭时通过AJAX(ASP.NET 2.0)-有条件 [ ^ ]
Have a look at this article: Partial update of parent page via AJAX (ASP.NET 2.0) on close of a child window - conditionally[^]


尝试仅在逗号后中断代码中的行

Try Break the line in code after comma only

protected void btnLookUp_Click(object sender, EventArgs e)
{
    string sScript = "<script>window.open(''a.aspx?textbox=" + TextBox1.Text.ToString() + "'',''cal'',
''left=10,top=10 resizable= yes scrollbars=yes'') </script>";
    RegisterClientScriptBlock("anything", sScript);
}



希望它能起作用



Hope it works


这篇关于在弹出窗口和主页之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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