Solved

Popup Window on Button Click for VB.NET

Posted on 2004-08-06
7
1,637 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 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