Solved

Popup Window on Button Click for VB.NET

Posted on 2004-08-06
7
1,633 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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