|
-
Apr 5th, 2007, 12:53 PM
#1
Thread Starter
New Member
Re: messagebox in asp.net
Within http://www.codeproject.com/aspnet/AspNetMsgBox.asp page, it says
"The MessageBox class in the System.Windows.Forms namespace is usable only from Windows Forms and NOT ASP.NET Web Forms. " For Web form, this page does have a nice C# class, named "MessageBox". Can someone convert it to vb.net and provide a asp.net example showing how to call it?
Parameters:
Title: string
Msg: String
buttons: Yes & No
Also, have asp.net recognize the resulting value of this MessageBox "pop up".
Thank you,
Jim
-
Apr 5th, 2007, 02:15 PM
#2
Re: messagebox in asp.net
Hi Jim, here is the converted C# code to VB.NET for you. I'm in a hurry but will be back online later. I can help more then 
Code:
Friend <PRE lang=cs id=pre1 style="MARGIN-TOP
Inherits 0px" nd="37">public class MessageBox
Private Shared m_executingPages As Hashtable = New Hashtable()
Private Sub New()
End Sub
Public Shared Sub Show(ByVal sMessage As String)
' If this is the first time a page has called this method then
If (Not m_executingPages.Contains(HttpContext.Current.Handler)) Then
' Attempt to cast HttpHandler as a Page.
Dim executingPage As Page = CType(IIf(TypeOf HttpContext.Current.Handler Is Page, HttpContext.Current.Handler, Nothing), Page)
If Not executingPage Is Nothing Then
' Create a Queue to hold one or more messages.
Dim messageQueue As Queue = New Queue()
' Add our message to the Queue
messageQueue.Enqueue(sMessage)
' Add our message queue to the hash table. Use our page reference
' (IHttpHandler) as the key.
m_executingPages.Add(HttpContext.Current.Handler, messageQueue)
' Wire up Unload event so that we can inject
' some JavaScript for the alerts.
AddHandler executingPage.Unload, AddressOf ExecutingPage_Unload
End If
Else
' If were here then the method has allready been
' called from the executing Page.
' We have allready created a message queue and stored a
' reference to it in our hastable.
Dim queue As Queue = CType(m_executingPages(HttpContext.Current.Handler), Queue)
' Add our message to the Queue
queue.Enqueue(sMessage)
End If
End Sub
' Our page has finished rendering so lets output the
' JavaScript to produce the alert's
Private Shared Sub ExecutingPage_Unload(ByVal sender As Object, ByVal e As EventArgs)
' Get our message queue from the hashtable
Dim queue As Queue = CType(m_executingPages(HttpContext.Current.Handler), Queue)
If Not queue Is Nothing Then
Dim sb As StringBuilder = New StringBuilder()
' How many messages have been registered?
Dim iMsgCount As Integer = queue.Count
' Use StringBuilder to build up our client slide JavaScript.
sb.Append("<script language='javascript'>")
' Loop round registered messages
Dim sMsg As String
Do While iMsgCount -= 1 > 0
sMsg = CStr(queue.Dequeue())
sMsg = sMsg.Replace(Constants.vbLf, "\n")
sMsg = sMsg.Replace("""", "'")
sb.Append("alert( """ & sMsg & """ );")
Loop
' Close our JS
sb.Append("</script>")
' Were done, so remove our page reference from the hashtable
m_executingPages.Remove(HttpContext.Current.Handler)
' Write the JavaScript to the end of the response stream.
HttpContext.Current.Response.Write(sb.ToString())
End If
End Sub
End Class
Private </PRE>
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 5th, 2007, 02:35 PM
#3
Re: messagebox in asp.net
You may also want to take a look at this: ASP.NET AJAX Control Toolkit: Modal Popup
-
Apr 5th, 2007, 03:30 PM
#4
Thread Starter
New Member
Re: messagebox in asp.net
Thank you both for the replies. Afterwards, I found similar vb.net code and made some changes. Using the asp.net and vb.net code below, is there a way to change the class to a function and return a boolean value back to asp.net?
--
-- ASP.net
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim strMessage As String
Dim approve as boolean
strMessage = "Do you want to save changes? click 'Ok' to save changes, else click cancel"
' MessageBox.Show(strMessage)
approve = MessageBox.Show(strMessage)
End Sub
</script>
--
-- vb.net app_code
Imports Microsoft.VisualBasic
Public Class MessageBox
Private Shared m_executingPages As New Hashtable()
Private Sub New()
End Sub 'New
Public Shared Sub Show(ByVal sMessage As String)
' If this is the first time a page has called this method then
If Not m_executingPages.Contains(HttpContext.Current.Handler) Then
' Attempt to cast HttpHandler as a Page.
Dim executingPage As Page = HttpContext.Current.Handler '
'ToDo: Error processing original source shown below
'
'
'--------------------------------------------------------^--- Syntax error: ';' expected
If Not (executingPage Is Nothing) Then
' Create a Queue to hold one or more messages.
Dim messageQueue As New Queue()
' Add our message to the Queue
messageQueue.Enqueue(sMessage)
' Add our message queue to the hash table. Use our page reference
' (IHttpHandler) as the key.
m_executingPages.Add(HttpContext.Current.Handler, messageQueue)
' Wire up Unload event so that we can inject
' some JavaScript for the alerts.
AddHandler executingPage.Unload, AddressOf ExecutingPage_Unload
End If
Else
' If were here then the method has allready been
' called from the executing Page.
' We have allready created a message queue and stored a
' reference to it in our hastable.
Dim queue As Queue = CType(m_executingPages(HttpContext.Current.Handler), Queue)
' Add our message to the Queue
queue.Enqueue(sMessage)
End If
End Sub 'Show
' Our page has finished rendering so lets output the
' JavaScript to produce the alert's
Private Shared Sub ExecutingPage_Unload(ByVal sender As Object, ByVal e As EventArgs)
' Get our message queue from the hashtable
Dim queue As Queue = CType(m_executingPages(HttpContext.Current.Handler), Queue)
If Not (queue Is Nothing) Then
Dim sb As New StringBuilder()
Dim sb2 = New StringBuilder()
Dim CRLF As String
sb2.append(Chr(13))
'sb2.append(LF)
CRLF = sb2.ToString()
' How many messages have been registered?
Dim iMsgCount As Integer = queue.Count
' Use StringBuilder to build up our client slide JavaScript.
sb.Append("<script language='javascript'>")
' Loop round registered messages
Dim sMsg As String
Dim sYes As String = "Glad you approve."
Dim sNo As String = "Nada"
While (iMsgCount > 0)
iMsgCount = iMsgCount - 1
sMsg = CStr(queue.Dequeue())
sMsg = sMsg.Replace(ControlChars.Lf, "\n")
sMsg = sMsg.Replace("""", "'")
' sb.Append("alert( """ + sMsg + """ );")
sb.Append("var answer = confirm( """ + sMsg + """ );")
sb.Append("if (answer == true)" + CRLF)
sb.Append("alert(" + "'" + sYes + "'" + ")" + CRLF)
sb.Append("else" + CRLF)
sb.Append("alert(" + "'" + sNo + "'" + ")")
End While
' Close our JS
sb.Append("</script>")
' Were done, so remove our page reference from the hashtable
m_executingPages.Remove(HttpContext.Current.Handler)
' Write the JavaScript to the end of the response stream.
HttpContext.Current.Response.Write(sb.ToString())
End If
End Sub 'ExecutingPage_Unload
End Class 'MessageBox
-
Apr 5th, 2007, 04:49 PM
#5
Addicted Member
Re: messagebox in asp.net
Here is how you use an alert:
Code:
Sub btn1_Click( ByVal sender As Object , ByVal e As System.EventArgs)
Dim script As String = "<script language=javascript>alert('Hello World');</scrip" & "t>"
Page.RegisterStartUpScript("myscript", script)
End Sub
F
-
Apr 5th, 2007, 11:14 PM
#6
Hyperactive Member
Re: messagebox in asp.net
Btw, In the Above code why </scrip" & "t>" can't be written as "</script>" ?
I am using .NET 2010 with Windows 7
-
Apr 6th, 2007, 12:59 AM
#7
Thread Starter
New Member
Re: messagebox in asp.net
Actually, I'm have a vb.net class containing a javascript message box (confirm). Now, I'm trying to receive the boolean result from that confirm and place it back into an asp.net variable.
-
Apr 6th, 2007, 02:51 AM
#8
Re: Messagebox in ASP.NET
Posts split to new thread
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 6th, 2007, 03:11 AM
#9
Addicted Member
Re: messagebox in asp.net
Re: Btw, In the Above code why </scrip" & "t>" can't be written as "</script>" ?
Try it...
It's "one of those things"...
F
-
Apr 6th, 2007, 03:21 AM
#10
Re: Messagebox in ASP.NET
All those classes and the rest (except for post #5) is overkill for a simple alert if I've ever seen one. Which I have. Therefore it is overkill.
-
Apr 6th, 2007, 01:05 PM
#11
Addicted Member
Re: Messagebox in ASP.NET
-
Apr 7th, 2007, 12:44 PM
#12
Lively Member
Re: Messagebox in ASP.NET
using javascript is a better option
-
Apr 7th, 2007, 01:12 PM
#13
Re: Messagebox in ASP.NET
 Originally Posted by mendhak
All those classes and the rest (except for post #5) is overkill for a simple alert if I've ever seen one. Which I have. Therefore it is overkill.
Froggy, I guess you forgot about my CodeBank thread:
http://vbforums.com/showthread.php?t=395604
But to return the results from a confirm alert is the question. Not just showing one.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 8th, 2007, 04:04 AM
#14
Re: messagebox in asp.net
 Originally Posted by ailill
Actually, I'm have a vb.net class containing a javascript message box (confirm). Now, I'm trying to receive the boolean result from that confirm and place it back into an asp.net variable.
Place a hidden field on your form. Set its runat attribute to runat="server".
Use Page.RegisterStartupScript with a confirm() instead of alert(), and have the return value written to the hidden field.
Then, access the hidden field from your codebehind.
-
Apr 8th, 2007, 03:17 PM
#15
Frenzied Member
Re: Messagebox in ASP.NET
This is making me think about my DebugConsole class. I don't have it here, but it:
Code:
var win = window.open("Javascript:document.write('')");
var dom = win.document.open();
dom.write("textbox-and-js-to-pass-back-val(window.opener.__doPostBack('PBEvent', 'value');)");//escaping is fun NATCH!!!
but, I'll post the vb code Monday; it really just gives you a window that you can write to and even post values back and forth with if your smart about javascript. I mostly use it to out put info when I can't use breakpoints...
Last edited by Magiaus; Apr 8th, 2007 at 05:13 PM.
Magiaus
If I helped give me some points.
-
Apr 9th, 2007, 12:08 PM
#16
Frenzied Member
Re: Messagebox in ASP.NET
Here is the code I said I would post.
Code:
Public Class JsDebugConsole
Inherits Control
Private Function JsEscapeString(ByVal str As String) As String
str = str.Replace("\", "\\")
str = str.Replace("""", "\""")
str = str.Replace("'", "\'")
str = str.Replace(vbCrLf, "\r\n")
str = str.Replace(vbCr, "\r")
str = str.Replace(vbLf, "\n")
str = str.Replace(vbTab, "\t")
Return str
End Function
Public Sub Write(ByVal str As String)
str = JsEscapeString(str)
Me.Page.RegisterStartupScript(Guid.NewGuid().ToString(), "<script language=""javascript"" type=""text/javascript"">DebugConsoleWrite('" & str & "');</script>")
End Sub
Public Sub WriteLine(ByVal str As String)
str = JsEscapeString(str)
Me.Page.RegisterStartupScript(Guid.NewGuid().ToString(), "<script language=""javascript"" type=""text/javascript"">DebugConsoleWriteLine('" & str & "');</script>")
End Sub
Public Sub WriteTable(ByVal caption As String, ByVal msg As String)
Dim tbl As String = "<table border=""1px"" cellpadding=""2"" cellspacing=""0"" style=""width:100%;border:solid 1px #000000;background-color:#000000;""><tr style=""background-color:silver;""><td>" & caption & "</td></tr><tr style=""background-color:white;""><td>" & msg & "</td></tr></table>"
WriteLine(tbl)
End Sub
Public Sub WriteErrorTable(ByVal msg As String)
WriteTable("Error", msg)
End Sub
Public Sub WriteErrorTable(ByVal e As Exception, ByVal complete As Boolean)
If complete = False Then
Dim tbl As String = "<table cellpadding=""0"" cellspacing=""2"" style=""width:100%;corder:solid 1px #000000""><tr><td>Error</td></tr><tr><td>" & e.Message & "</td></tr><tr><td>" & e.StackTrace & "</td></tr><tr><td>" & e.Source & "</td></tr><tr><td>Source Member:" & e.TargetSite.Name & "</td></tr></table>"
WriteLine(tbl)
Else
Dim sbOut As System.Text.StringBuilder = New System.Text.StringBuilder
Dim ce As Exception = e
sbOut.Append("<table><tr><td>Error Group</td><tr><td>")
While Not ce Is Nothing
sbOut.Append("<table cellpadding=""0"" cellspacing=""2"" style=""width:100%;corder:solid 1px #000000""><tr><td>Error</td></tr><tr><td>" & ce.Message & "</td></tr><tr><td>" & e.StackTrace & "</td></tr><tr><td>" & ce.Source & "</td></tr></table>")
If ce.InnerException Is Nothing Then Exit While
ce = ce.InnerException
End While
sbOut.Append("</td></tr></table>")
WriteErrorTable(sbOut.ToString())
End If
End Sub
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
Dim js As String = "var debugWindow = null;var debugConsole = null;function DebugConsoleLoad(){var url = ""javascript:document.write('<body style=background-color:silver;color:black;font-size:12px;>Debug Console:<br />\r\n</body>');"";var nm = ""DEBUG""/*+ Math.floor(Math.random() * 100000).toString()*/;var ftrs = ""top=10,left=10,width=300,height=300,scrollbars=yes,menubar=yes,location=no,resizable=yes,toolbar=yes"";debugWindow = window.open(url,nm,ftrs, true);debugConsole = debugWindow.document.open(""javascript:document.write('Debug Console:<br />\r\n');"");debugConsole.write('<title>Debug Output[' + document.location.href + ']</title>');}function DebugConsoleCheck(){if(debugConsole == null) DebugConsoleLoad();}function DebugConsoleWrite(str){DebugConsoleCheck();try{debugConsole.write(str);}catch(e){DebugConsoleLoad();debugConsole.write(str);}debugConsole.body.scrollTop=debugConsole.body.scrollHeight;}function DebugConsoleWriteLine(str){DebugConsoleWrite(str + ""<br />\r\n"");}"
Me.Page.RegisterClientScriptBlock("JsDebugConsole", "<script language=""javascript"" type=""text/javascript"">" & js & "</script>")
MyBase.OnPreRender(e)
End Sub
End Class
Magiaus
If I helped give me some points.
-
Apr 9th, 2007, 06:07 PM
#17
Thread Starter
New Member
Re: Messagebox in ASP.NET
Thank you for the posts. By the way, the JsDebugConsole has some obsolete code reference warnings.
Warning 1 'Public Overridable Sub RegisterStartupScript(key As String, script As String)' is obsolete: 'The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202'
Me.Page.RegisterStartupScript(Guid.NewGuid().ToString(), "<script language=""javascript"" type=""text/javascript"">DebugConsoleWrite('" & str & "');</script>")
-
Apr 10th, 2007, 08:45 AM
#18
Frenzied Member
Re: Messagebox in ASP.NET
 Originally Posted by ailill
Thank you for the posts. By the way, the JsDebugConsole has some obsolete code reference warnings.
Warning 1 'Public Overridable Sub RegisterStartupScript(key As String, script As String)' is obsolete: 'The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202'
Me.Page.RegisterStartupScript(Guid.NewGuid().ToString(), "<script language=""javascript"" type=""text/javascript"">DebugConsoleWrite('" & str & "');</script>")
I'm aware but it has to work in 2k1, 2k3, and 2k5 so....
Magiaus
If I helped give me some points.
-
Apr 10th, 2007, 04:36 PM
#19
Re: Messagebox in ASP.NET
Not much changes, just a few namespace gripes.
-
Apr 10th, 2007, 06:47 PM
#20
Thread Starter
New Member
Re: Messagebox in ASP.NET
Sorry, folks. I still have a disconnect. How do you store the javascript value back to a hidden field? Since I have some preliminary validation function, I'm not using a button event. Here is the simplified asp.net code.
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim bResult As Boolean
Dim strMessage As String = "Do you want to save changes? click Ok to save changes, else click cancel"
Dim script As String = "<script language='javascript'>var answer = confirm('" & strMessage & "');</scrip" & "t>"
' HiddenField1 = Page.RegisterStartupScript("myscript", script)
Me.Page.RegisterStartupScript(Guid.NewGuid().ToString(), script)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Test Message Box (msg4.aspx)</title>
</head>
<body>
<h3>Test the Message Popup</h3>
<form runat="server">
<asp:HiddenField ID="HiddenField1" runat="server" />
</form>
</body>
</html>
Last edited by ailill; Apr 10th, 2007 at 06:51 PM.
Reason: resitrictions
-
Apr 10th, 2007, 07:32 PM
#21
Thread Starter
New Member
A different, but complete solution by Gayan Peiris
Use inherits with namespace.
From Gayan Peiris
http://www.codeguru.com/Csharp/.NET/...cle.php/c5337/
---
Code:
<%@ Page language="vb" AutoEventWireup="false" Inherits="EmbeddingScripts4.WebForm1" CodeFile="WebForm1.aspx.vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" content="VB">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 164px; POSITION: absolute; TOP: 63px" runat="server" Text="Submit"></asp:Button>
<asp:Label id="Label1" style="Z-INDEX: 107; LEFT: 107px; POSITION: absolute; TOP: 22px" runat="server">Please click the Submit Button.</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 106; LEFT: 65px; POSITION: absolute; TOP: 258px" runat="server">Above text box will fill with popup window data.</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 102; LEFT: 110px; POSITION: absolute; TOP: 117px" runat="server" TextMode="MultiLine" Height="109px"></asp:TextBox>
</form>
</body>
</HTML>
--
<%@ Page language="vb" AutoEventWireup="false" Inherits="EmbeddingScripts4.PopUpWindow" CodeFile="PopUpWindow.aspx.vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PopUpWindow</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" content="VB">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 105; LEFT: 241px; POSITION: absolute; TOP: 222px" runat="server" Text="Submit"></asp:Button>
<asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 32px; POSITION: absolute; TOP: 76px" runat="server">Enter Text</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 104; LEFT: 154px; POSITION: absolute; TOP: 76px" runat="server" TextMode="MultiLine" Height="104px" Width="246px"></asp:TextBox>
</form>
</body>
</HTML>
--
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Namespace EmbeddingScripts4
''' <summary>
''' Summary description for PopUpWindow.
''' </summary>
Partial Class PopUpWindow
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Put user code to initialize the page here
End Sub
#Region "Web Form Designer generated code"
Overrides Protected Sub OnInit(ByVal e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
' Me.Button1.Click += New System.EventHandler(Me.Button1_Click);
' Me.Load += New System.EventHandler(Me.Page_Load);
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
'Script passing data to main page
Dim Script As String = ""
Script &= Constants.vbLf & "<script language=JavaScript id='test1'>" & Constants.vbLf
Dim data As String = String.Empty
data = TextBox1.Text
Script &= "window.opener.addOption('" & data & "'); "
Script &= "self.close();"
Script &= "</script>"
'Check whether it is already registerd.
If (Not Me.IsClientScriptBlockRegistered("test1")) Then
'Register the script
Me.RegisterClientScriptBlock("test1", Script)
End If
End Sub
End Class
End Namespace
Last edited by RobDog888; Apr 11th, 2007 at 05:03 PM.
Reason: Added [code] tags for easier reading
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|