Solved

Popup Window on Button Click for VB.NET

Posted on 2004-08-06
7
1,624 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

13 Experts available now in Live!

Get 1:1 Help Now