用asp.net打开一个新窗口

时间:2022-08-04 21:16:16

Im new into that asp.net thing, but here goes.

我是asp.net的新手,但这里有。

I got at ImageButton, and when its clicked i want the image displayed in another window. If I can avoid using ajax i would like to do that. If possible would like to make the window modal, but still avoid ajax, since Im not ready to mix more technolgies yet.

我得到了ImageButton,当它点击时我希望图像显示在另一个窗口中。如果我可以避免使用ajax我想这样做。如果可能的话想制作窗口模态,但仍然避免使用ajax,因为我还没准备好混合更多的技术。

7 个解决方案

#1


IMHO the best practice to show a picture is in the same page on the top of the content. I personally use Lightbox. You can find the documentation on their page, so it should be easy for you to integrate their JavaScript code.

恕我直言,显示图片的最佳做法是在内容的顶部相同的页面。我个人使用Lightbox。您可以在他们的页面上找到文档,因此您可以轻松地集成他们的JavaScript代码。

#2


The existing answers with JavaScript are fine, but just to suggest an alternative - could you use a HyperLink (with an ImageUrl set so you still get an image) and set its Target property instead?

使用JavaScript的现有答案很好,但只是建议一个替代方案 - 您可以使用HyperLink(设置ImageUrl以便仍然获得图像)并设置其Target属性吗?

#3


Somewhat like this:

有点像这样:

<asp:ImageButton ID="imbJoin" CssClass="btn-find" AlternateText="Find" ToolTip="Find" runat="server" ImageUrl="~/library/btn-find.gif" onClick="javascript:popUp("ServicesLocator.aspx")" />

Resource: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22832169.html

Using the ImageButton you need to use a JavaScript to open it in a new window. You can also look into the OnClientClick-event

使用ImageButton,您需要使用JavaScript在新窗口中打开它。您还可以查看OnClientClick事件

#4


You can use the ImageButton's OnClientClick property:

您可以使用ImageButton的OnClientClick属性:

<asp:ImageButton ... OnClientClick="javascript:window.open('url_to_image');" >

But this popup window will not be modal.

但是这个弹出窗口不是模态的。

#5


The following javascript will do what you're looking for:

以下javascript将执行您正在寻找的内容:

window.open('page.html','WindowTitle','width=400,height=200')

#6


It might be worth pointing to a two relevant entries in the excellent EFNet's #javascript FAQ:

可能值得指出优秀的EFNet #javascript常见问题解答中的两个相关条目:

  1. Correct Use of Popups - yay accessibility!
  2. 正确使用弹出窗口 - 可访问性!

  3. How do I make a popup window the same size as my image?
  4. 如何使弹出窗口与我的图像大小相同?

  5. How do I create a custom 'OK' dialog or something similar? - modal windows are not that useful and something like the suggested Lightbox or similar scripts would be better "modal" options
  6. 如何创建自定义“确定”对话框或类似的对话框? - 模态窗口没有那么有用,像建议的Lightbox或类似的脚本会更好“模态”选项

  7. Correct Use of Links - this one being only partly on-topic but the previous answers use of the "javascript:" pseudo protocol made it necessary: it is never required nor useful in a web page that should work across browsers. After all, JavaScript is the default (and only) scripting language.
  8. 正确使用链接 - 这一部分只是部分主题,但之前的答案使用“javascript:”伪协议使其成为必要:它在从不适用于浏览器的网页中永远不需要也没用。毕竟,JavaScript是默认的(也是唯一的)脚本语言。

#7


Thank you for all the answers! I ended up using lightbox I found this example http://neutrongenious.wordpress.com/2007/09/08/lightbox-for-asp-net-2-0/

谢谢你的所有答案!我最终使用灯箱我发现这个例子http://neutrongenious.wordpress.com/2007/09/08/lightbox-for-asp-net-2-0/

And it works perfectly

而且效果很好

#1


IMHO the best practice to show a picture is in the same page on the top of the content. I personally use Lightbox. You can find the documentation on their page, so it should be easy for you to integrate their JavaScript code.

恕我直言,显示图片的最佳做法是在内容的顶部相同的页面。我个人使用Lightbox。您可以在他们的页面上找到文档,因此您可以轻松地集成他们的JavaScript代码。

#2


The existing answers with JavaScript are fine, but just to suggest an alternative - could you use a HyperLink (with an ImageUrl set so you still get an image) and set its Target property instead?

使用JavaScript的现有答案很好,但只是建议一个替代方案 - 您可以使用HyperLink(设置ImageUrl以便仍然获得图像)并设置其Target属性吗?

#3


Somewhat like this:

有点像这样:

<asp:ImageButton ID="imbJoin" CssClass="btn-find" AlternateText="Find" ToolTip="Find" runat="server" ImageUrl="~/library/btn-find.gif" onClick="javascript:popUp("ServicesLocator.aspx")" />

Resource: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22832169.html

Using the ImageButton you need to use a JavaScript to open it in a new window. You can also look into the OnClientClick-event

使用ImageButton,您需要使用JavaScript在新窗口中打开它。您还可以查看OnClientClick事件

#4


You can use the ImageButton's OnClientClick property:

您可以使用ImageButton的OnClientClick属性:

<asp:ImageButton ... OnClientClick="javascript:window.open('url_to_image');" >

But this popup window will not be modal.

但是这个弹出窗口不是模态的。

#5


The following javascript will do what you're looking for:

以下javascript将执行您正在寻找的内容:

window.open('page.html','WindowTitle','width=400,height=200')

#6


It might be worth pointing to a two relevant entries in the excellent EFNet's #javascript FAQ:

可能值得指出优秀的EFNet #javascript常见问题解答中的两个相关条目:

  1. Correct Use of Popups - yay accessibility!
  2. 正确使用弹出窗口 - 可访问性!

  3. How do I make a popup window the same size as my image?
  4. 如何使弹出窗口与我的图像大小相同?

  5. How do I create a custom 'OK' dialog or something similar? - modal windows are not that useful and something like the suggested Lightbox or similar scripts would be better "modal" options
  6. 如何创建自定义“确定”对话框或类似的对话框? - 模态窗口没有那么有用,像建议的Lightbox或类似的脚本会更好“模态”选项

  7. Correct Use of Links - this one being only partly on-topic but the previous answers use of the "javascript:" pseudo protocol made it necessary: it is never required nor useful in a web page that should work across browsers. After all, JavaScript is the default (and only) scripting language.
  8. 正确使用链接 - 这一部分只是部分主题,但之前的答案使用“javascript:”伪协议使其成为必要:它在从不适用于浏览器的网页中永远不需要也没用。毕竟,JavaScript是默认的(也是唯一的)脚本语言。

#7


Thank you for all the answers! I ended up using lightbox I found this example http://neutrongenious.wordpress.com/2007/09/08/lightbox-for-asp-net-2-0/

谢谢你的所有答案!我最终使用灯箱我发现这个例子http://neutrongenious.wordpress.com/2007/09/08/lightbox-for-asp-net-2-0/

And it works perfectly

而且效果很好