calling popup window from .NET?

Netnoobie

Well-known member
Joined
Feb 6, 2003
Messages
94
Location
Philadelphia
Hello all! Have an ASPX page that really should be called in a pop up window. How can I call a pop up window from .NET? I cant seem to find much on it anywhere, and need to use this functionality throughout this project.

Many thanks!
 
You can create a new aspx file (maybe call it Popup) and in the calling form put some javascript. Sorry I only know how to do it with JS
Code:
		<SCRIPT>
			function fnOpenPopup(sPage,sArgs,sFeatures,bMode)
			{
			if (bMode == Modal)
				window.showModelessDialog(sPage, sArgs, sFeatures);
			else
				window.open(sPage, sArgs, sFeatures);	
			}
		</SCRIPT>

If you want to use this method Ill give you the parameters required.
 
You can play around with the Features to suite your needs...
Code:
Dim sURL As String = "Your_Popup.aspx?SomeString="
Dim sArgs As String = "someargsServiceDefinitions"
Dim sFeaturesModeless As String = "menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=800,height=400"
Dim sFeaturesModal As String = "dialogHeight:500px;dialogWidth:500px;dialogTop:100px;dialogLeft:100px;edge:Raised;center:1;help:0;resizable:1;status:0;scroll:1"
Dim sMode As String = "Modal"
 
Oh yeah, to call it from an <a href>....
Code:
"<a href=javascript:fnOpenPopup(" & sURL & "," & sArgs & strArray(intCounter, 1) & "," & sFeaturesModeless & "," & sMode & ")>Some Text</a>"
 
Ok, now this will show just how new I am to NET. How can I use the code youve given me with codebehind? In my code Ive set the HREF like:
Code:
Link1.NavigateUrl = "java script:fnOpenPopup(" & sURL & "," & sFeaturesModeless & "," & sMode & ")"
With the <SCRIPT> tags in the aspx page. The variables are being populated so thats not a problem. Heres what is in the propeties of the link at runtime:
Code:
[url]http://localhost/Citadel/java%20script:fnOpenPopup[/url](AddNewLocation.aspx,%20menubar=no,toolbar=no,status=no,scrollbars=yes,resizable=yes,width=800,height=400,Modal)
So its sticking the string at the end of the //localhost URL. What is the way around this?

Just trying to wade through this NET stuff.
Many Thanks.
 
How would you do this with the code behind method?

I find that when I click a button, it kicks off the page.ispostback bing true and sends me back to the login page

If I page through that and force the button click event, then it doesnt see Window as a valid object
 
I sort of streamlined (for my testing purposes at least) what was given to me. This is in the aspx header:
Code:
<SCRIPT>
			function fnOpenPopup(sPage,sFeatures,bMode)
			{	
			  window.open(sPage, NewWin, sFeatures)
			}
		</SCRIPT>

And this give the link the URL:
Code:
  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Not Page.IsPostBack Then
      BindDDL()
    End If
    Link1.NavigateUrl = "javascript:fnOpenPopup(AddNewLocation.aspx,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,width=375,height=250,left=401,top=250,Modal)"
  End Sub

Of course Im using a Hyperlink, but its the same idea.
 
Back
Top