|
 |
aspx thread: Show a popup window on aspx page
Message #1 by "Nguyen Ha Giang" <giang@c...> on Fri, 7 Jun 2002 08:19:46 +0700
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_0104_01C20DFC.1565D4B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Dear all,
I'm creating a apsx page and I want to show popup window when user click
asp button. This code to show window must put on apsx.cs file (server-
behind code) not script on HTML file.
....
public class WebForm1 : System.Web.UI.Page
{
...
private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
// Code to show popup window here!!!
}
}
Thanks for reading,
Giang
Message #2 by Terrence Joubert <Terrence@v...> on Fri, 7 Jun 2002 07:27:07 +0400
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C20DD3.3806AAC0
Content-Type: text/plain
There is no way that this can happen directly since the server has no
control over the execution at the client. This has to be done through client
script.
However, you can use the Server.Transfer(aspPage.asp) method and redirect
the execution to another asp page that has client script to open a popup
window. If you definitely need an ImageButton as a server control, then I
suggest that you use the System.Web.UI.HtmlControls.HtmlImage control that
has support for both server side and client side code.
Hope this helps
Terrence
-----Original Message-----
From: Nguyen Ha Giang [mailto:giang@c...]
Sent: Friday, June 07, 2002 5:20 AM
To: ASP+
Subject: [aspx] Show a popup window on aspx page
Dear all,
I'm creating a apsx page and I want to show popup window when user click asp
button. This code to show window must put on apsx.cs file (server- behind
code) not script on HTML file.
....
public class WebForm1 : System.Web.UI.Page
{
...
private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
// Code to show popup window here!!!
}
}
Thanks for reading,
Giang
--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
Message #3 by "Matt Dittman" <mddittman@h...> on Fri, 7 Jun 2002 13:01:02
|
|
What I did was put the client side script in some Response.Write's in a
server side function, and it works pretty well. It still results in
script being placed on the HTML page, but there's no way around that...
private void ImageButton1_Click(object sender, =
System.Web.UI.ImageClickEventArgs e)
{
//add modal dialog to select customer
Response.Write("<script language=javascript>\n" +
"function winLdr(){\n" +
"totalx = window.screen.availWidth;\n" +
"totaly = window.screen.availHeight;\n" +
"posx = (totalx - 500) / 2;\n" +
"posy = (totaly - 300) / 2;\n" +
"win = \"width=500,height=300,top=\" +
posy + \",left=\" + posx +\",\";\n" +
"win = win + "\"scrollbars=no,menubar=no," +
"toolbar=no,location=no,status=no;directories=no," +
"resizeable=no\";\n" + "strURL = \"myURL.aspx" + "\"\n" +
"statWin = window.open(strURL, \"MyWin\", win);\n" +
"statWin.focus();}\n" +
"winLdr();</script>");
}
Dear all,
I'm creating a apsx page and I want to show popup window when user click
asp button. This code to show window must put on apsx.cs file (server-
behind code) not script on HTML file.
....
public class WebForm1 : System.Web.UI.Page
{
...
private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
// Code to show popup window here!!!
}
}
Thanks for reading,
Giang
Message #4 by Feduke Cntr Charles R <FedukeCR@m...> on Fri, 7 Jun 2002 06:00:54 -0700
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C20E23.5BB52E80
Content-Type: text/plain
Okay, this can be done without the use of script, but not handled by the
server. There's an attribute in an <a> tag called "target", and you could
do something like this:
<a href="whatever.aspx" target="new">Click!</a>
So its technically not script, but it should work in downlevel browsers.
- Chuck
-----Original Message-----
From: Terrence Joubert [mailto:Terrence@v...]
Sent: Thursday, June 06, 2002 11:27 PM
To: ASP+
Subject: [aspx] RE: Show a popup window on aspx page
Importance: High
There is no way that this can happen directly since the server has no
control over the execution at the client. This has to be done through client
script.
However, you can use the Server.Transfer(aspPage.asp) method and redirect
the execution to another asp page that has client script to open a popup
window. If you definitely need an ImageButton as a server control, then I
suggest that you use the System.Web.UI.HtmlControls.HtmlImage control that
has support for both server side and client side code.
Hope this helps
Terrence
-----Original Message-----
From: Nguyen Ha Giang [mailto:giang@c...]
Sent: Friday, June 07, 2002 5:20 AM
To: ASP+
Subject: [aspx] Show a popup window on aspx page
Dear all,
I'm creating a apsx page and I want to show popup window when user click asp
button. This code to show window must put on apsx.cs file (server- behind
code) not script on HTML file.
....
public class WebForm1 : System.Web.UI.Page
{
...
private void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
// Code to show popup window here!!!
}
}
Thanks for reading,
Giang
--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
--- Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to
Message #5 by "Mingkun Goh" <mangokun@h...> on Mon, 10 Jun 2002 02:36:43
|
|
You can try either of the following and see whether it fits.
This does not trigger post-back when you click on the button, but it
requires you to already know which page you want to load in the popop
window:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ImageButton1.Attributes.Add("onclick", "javascript:window.open
('Test.aspx','Test
Page','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,r
esizable=0,width=screen.width,height=screen.Height,left=0,top=0').focus
();return false;")
End If
End Sub
Or this:
This triggers a page post-back, but the advantage is that in the Click
event, you can dynamically change which page you want to load in the popop
window:
Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnResetCalendar.Click
'Form the script that is to be registered at client side.
Dim scriptString As String = "<script language=JavaScript>"
scriptString += "window.open('Test.aspx','Test
Page','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,r
esizable=0,width=screen.width,height=screen.Height,left=0,top=0').focus()"
scriptString += "</script>"
If Not IsStartupScriptRegistered("Startup") Then
RegisterStartupScript("Startup", scriptString)
End If
End Sub
Note: I am more comfortable in VB.NET, thus the code above is in VB.
|
|
 |