Solved

Popup Window on Button Click for VB.NET

Posted on 2004-08-06
7
1,632 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Single Form 8 42
Get size of each directory on each mapped drive 5 29
Regex validation 2 25
MailAddress in vb 4 17
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…

832 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