Solved

Popup Window on Button Click for VB.NET

Posted on 2004-08-06
7
1,627 Views
Last Modified: 2012-06-27
Hi Experts,

I have a VB.NET webform and need to create a popup window after the user clicks on either a button, or image that I place on the form.  The popup window will contain a paragraph explaining the function about the report form that the button or image will be sitting next to.  All static text and so forth inside the popup window.  I'm new to VB.NET so the more specific the instructions the better.  Thanks a lot!!
0
Comment
Question by:officerhandsome
7 Comments
 
LVL 7

Expert Comment

by:natloz
ID: 11738642
MsgBox("Line 1." + vbCrLf + "Line 2." + vbCrLf + "Line 3.")
0
 

Author Comment

by:officerhandsome
ID: 11738676
I'm going to need way more than that.  I have no idea where to put that code.  Do I put it in the button click?(no, because I got a huge error)  Do I put that on the HTML side of the form, and if so, Where?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 11738704
That won't work on a web page without a little magic:)

Here's an example using Java:

http://www.codeguru.com/Csharp/.NET/net_asp/scripting/article.php/c5337/

Bob
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:officerhandsome
ID: 11738871
Thanks Bob, took a little work but I got it down.  I'll learn that Javascript before long!!!

Thanks
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11738881
Here's the code TheLearnedOne reference converted to VB.Net from C#

Private Sub Button1_Click(ByVal sender As Or, ByVal e As System.EventArgs) Handles Button1.Click

  Dim PopUpWindowPage As String = "PopUpWindow.aspx"

  'Script for popup window
  Dim PopupScript As New StringBuilder   'StringBuilder is more efficient than appending strings...
  PopupScript.Append("\n<script language=JavaScript id='PopupWindow'>\n")
  PopupScript.Append("var confirmWin = null; \n")
  PopupScript.Append("confirmWin = window.open('"+PopUpWindowPage+"',  'Your Content Goes HERE', 'width=455,height=435, status'); \n")
  PopupScript.Append("if((confirmWin != null) && (confirmWin.opener==null)) { \n")
  PopupScript.Append("  confirmWin.opener = self; \n")
  PopupScript.Append("}\n")
  PopupScript.Append("</script>")

  //Script for displaying popup window information in main window
  Dim ParentLoadScript As New StringBuilder()
  ParentLoadScript.Append("\n<script language=JavaScript id='ParentLoad'>\n")
  ParentLoadScript.Append("function addOption(strValue){ \n")
  ParentLoadScript.Append("var objForm = document.forms['Form1'];\n")
  ParentLoadScript.Append("var objFormField = objForm.elements['TextBox1'];\n")
  ' ParentLoadScript.Append("alert(objFormField);\n")
  ParentLoadScript.Append(" if (objFormField != null))
  ParentLoadScript.Append("objFormField.value = (strValue); }\n")
  ParentLoadScript.Append("</script>")

  'Check whether they are already registered
  If Not Me.IsStartupScriptRegistered("PopupWindow") Then
    ' Register the script
    Me.RegisterStartupScript("PopupWindow", PopupScript.ToString)
  End If


  ' Check whether they are already registered
  If Not Me.IsStartupScriptRegistered("ParentLoad") Then
    ' Register the script
    Me.RegisterStartupScript("ParentLoad",ParentLoadScript.ToString)
  End If
End Sub

0
 

Author Comment

by:officerhandsome
ID: 11738926
So how would I make this line of code:

<input type="button" onClick="pop_window()" Value="Open Window" style="Z-INDEX: 153; LEFT: 248px; POSITION: absolute; TOP: 160px">

work so that it was a graphic image that I wanted the user to click on to raise the popup window rather than a button?
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11738982
<img alt="" src="..\images\button.jpg" onclick="Pop_Window()" />
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now