将图像按钮ID绑定到window.open方法 [英] bind image button id to window.open method

查看:54
本文介绍了将图像按钮ID绑定到window.open方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生.

我有两页. a.aspx,b.aspx. a.aspx中有4个按钮,当我们单击button1或button2或button3或button4时,应打开新窗口.每个按钮都有一些不同的功能.
我的疑问是如何将每个按钮绑定到window.open方法.

如果有人知道,请帮助我.

我的代码如下:

a.aspx
------

hello sir.

I have two pages. a.aspx, b.aspx. There are 4 buttons in a.aspx, when we click button1 or button2 or button3 or button4 new window should be opened. and there is some different functionality for each button.
my doubt is how bind each button to window.open method.

If any body know please help me.

My code is below:

a.aspx
------

<script type="text/javascript">
        function openwindow() {
            window.open("AllPageDetails.aspx", "mywindow", "menubar=1,resizable=1,width=350,height=250");
        }

    </script>


<asp:ImageButton ID="ImgBtnCategory" runat="server" OnClientClick="openwindow()" PostBackUrl ="~/AllPageDetails.aspx?ImgBtnCategory=Category"/>



b.aspx
------



b.aspx
------

if (Request.QueryString["ImgBtnCategory"] == "one")
            {
                LblId.Text = "Actor Id";
                LblName.Text = "Actor Name";
                TxtExtra.Visible = false;
            }

推荐答案

我将禁用postbackurl:
I would disable the postbackurl:
PostBackUrl ="JavaScript.Void(1);"


然后更改javascript函数:


then change javascript function:

<script type="text/javascript">
       function openwindow(id) {
       window.open("AllPageDetails.aspx?id=" + id, "mywindow", "menubar=1,resizable=1,width=350,height=250");
        }
    </script>



并从您的OnClientClick传递此ID:



And pass this id from your OnClientClick:

OnClientClick="openwindow(1);" 



之后,您将在服务器端进行处理以显示正确的结果.



After that you will handle this is on the server side to display the proper result.


这篇关于将图像按钮ID绑定到window.open方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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