473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using createPopup on a single button.

I have a contextmenu that I only want to show when right clicking on a
single button. I have the menu working but it happens on the entire page.
What am I doing wrong?

Thanks

Private Sub ContextMenu()

Dim ConnectionString As String =
ConfigurationSettings.AppSettings("ConnectionStrin g")

Dim RowCount As Integer

Dim IDCount As Integer

Dim CommandText As String = "SELECT DISTINCT um.corigin AS Origin, g1.name
AS OriginName "

CommandText += "FROM tmpUnitMove um "

CommandText += "LEFT JOIN tmpUnits u ON um.uitempunitkey =
u.uitempunitkey "

CommandText += "LEFT JOIN geofile g1 ON um.corigin = g1.geo "

CommandText += "WHERE um.csessionid = '" & Session.SessionID & "' OR
um.cSaveSessionId = '" & Session.SessionID & "'"

CommandText += "ORDER BY g1.name"

Dim myConnection As New SqlConnection(ConnectionString)

Dim myCommand As New SqlDataAdapter(CommandText, myConnection)

Dim HTML As New System.Text.StringBuilder

Dim ds As New DataSet

Dim dsRow As DataRow

myCommand.Fill(ds)

RowCount = ds.Tables(0).Rows.Count

Dim NameWidth As Integer = 0

For Each dsRow In ds.Tables(0).Rows

If Len(dsRow.Item("OriginName")) > NameWidth Then

NameWidth = Len(dsRow.Item("OriginName"))

End If

Next

IDCount = 0

With HTML

.Append("<TABLE STYLE=""border:1pt solid #808080"" BGCOLOR=""#FFFFFF""
WIDTH=""")

.Append(NameWidth * 8)

.Append(""" HEIGHT=""")

.Append(RowCount * 25)

.Append(""" CELLPADDING=""0"" CELLSPACING=""1"">")

.Append("<STYLE TYPE=""Styles/css"">\n")

.Append("a:link {text-decoration:nonefont-family:Arialfont-size:8pt}\n")

.Append("a:visited
{text-decoration:nonefont-family:Arialfont-size:8pt}\n")

.Append("td {font-size:8pt}\n")

.Append("</STYLE>\n")

For Each dsRow In ds.Tables(0).Rows

.Append("<TR><TD ID=Row")

.Append(IDCount)

.Append(" STYLE=""border:1pt solid #FFFFFF""
ONMOUSEOVER=""document.all.Row")

.Append(IDCount)

.Append(".style.background=\'highlight\';document. all.Row")

.Append(IDCount)

.Append(".style.border=\'1pt solid #FFFFFF\';""
ONMOUSEOUT=""document.all.Row")

.Append(IDCount)

.Append(".style.background=\'#FFFFFF\';document.al l.Row")

.Append(IDCount)

.Append(".style.border=\'1pt solid #FFFFFF\';""
ONCLICK=""window.history.go(-1);"">")

.Append(dsRow.Item("OriginName"))

.Append("</TD></TR>")

IDCount += 1

Next

.Append("</TABLE>")

End With

Dim Script As New System.Text.StringBuilder

With Script

.Append("<Script Language=JavaScript>")

.Append("var oPopup = window.createPopup();")

.Append("function dopopup(x,y) {")

.Append("var oPopupBody = oPopup.document.body;")

.Append("oPopupBody.innerHTML = '" & HTML.ToString & "';
oPopupBody.style.cursor=""hand"";")

.Append("oPopup.show(x, y, ")

.Append(NameWidth * 8)

.Append(", ")

.Append(RowCount * 25)

.Append(", document.body);")

.Append("}")

.Append("document.oncontextmenu = function() {
dopopup(event.x,event.y);return false; }")

.Append("</Script>")

End With

RegisterStartupScript("ContextMenu", Script.ToString)

End Sub
Nov 18 '05 #1
1 1311
Without analyzing the attached code I can guess that you are attaching the
contextmenu event handler to the document. You should do it for the button
instead.

Eliyahu

"Thomasa Gregg" <th**********@yahoo.com> wrote in message
news:e3**************@TK2MSFTNGP14.phx.gbl...
I have a contextmenu that I only want to show when right clicking on a
single button. I have the menu working but it happens on the entire page.
What am I doing wrong?

Thanks

Private Sub ContextMenu()

Dim ConnectionString As String =
ConfigurationSettings.AppSettings("ConnectionStrin g")

Dim RowCount As Integer

Dim IDCount As Integer

Dim CommandText As String = "SELECT DISTINCT um.corigin AS Origin, g1.name
AS OriginName "

CommandText += "FROM tmpUnitMove um "

CommandText += "LEFT JOIN tmpUnits u ON um.uitempunitkey =
u.uitempunitkey "

CommandText += "LEFT JOIN geofile g1 ON um.corigin = g1.geo "

CommandText += "WHERE um.csessionid = '" & Session.SessionID & "' OR
um.cSaveSessionId = '" & Session.SessionID & "'"

CommandText += "ORDER BY g1.name"

Dim myConnection As New SqlConnection(ConnectionString)

Dim myCommand As New SqlDataAdapter(CommandText, myConnection)

Dim HTML As New System.Text.StringBuilder

Dim ds As New DataSet

Dim dsRow As DataRow

myCommand.Fill(ds)

RowCount = ds.Tables(0).Rows.Count

Dim NameWidth As Integer = 0

For Each dsRow In ds.Tables(0).Rows

If Len(dsRow.Item("OriginName")) > NameWidth Then

NameWidth = Len(dsRow.Item("OriginName"))

End If

Next

IDCount = 0

With HTML

.Append("<TABLE STYLE=""border:1pt solid #808080"" BGCOLOR=""#FFFFFF""
WIDTH=""")

.Append(NameWidth * 8)

.Append(""" HEIGHT=""")

.Append(RowCount * 25)

.Append(""" CELLPADDING=""0"" CELLSPACING=""1"">")

.Append("<STYLE TYPE=""Styles/css"">\n")

.Append("a:link {text-decoration:nonefont-family:Arialfont-size:8pt}\n")
.Append("a:visited
{text-decoration:nonefont-family:Arialfont-size:8pt}\n")

.Append("td {font-size:8pt}\n")

.Append("</STYLE>\n")

For Each dsRow In ds.Tables(0).Rows

.Append("<TR><TD ID=Row")

.Append(IDCount)

.Append(" STYLE=""border:1pt solid #FFFFFF""
ONMOUSEOVER=""document.all.Row")

.Append(IDCount)

.Append(".style.background=\'highlight\';document. all.Row")

.Append(IDCount)

.Append(".style.border=\'1pt solid #FFFFFF\';""
ONMOUSEOUT=""document.all.Row")

.Append(IDCount)

.Append(".style.background=\'#FFFFFF\';document.al l.Row")

.Append(IDCount)

.Append(".style.border=\'1pt solid #FFFFFF\';""
ONCLICK=""window.history.go(-1);"">")

.Append(dsRow.Item("OriginName"))

.Append("</TD></TR>")

IDCount += 1

Next

.Append("</TABLE>")

End With

Dim Script As New System.Text.StringBuilder

With Script

.Append("<Script Language=JavaScript>")

.Append("var oPopup = window.createPopup();")

.Append("function dopopup(x,y) {")

.Append("var oPopupBody = oPopup.document.body;")

.Append("oPopupBody.innerHTML = '" & HTML.ToString & "';
oPopupBody.style.cursor=""hand"";")

.Append("oPopup.show(x, y, ")

.Append(NameWidth * 8)

.Append(", ")

.Append(RowCount * 25)

.Append(", document.body);")

.Append("}")

.Append("document.oncontextmenu = function() {
dopopup(event.x,event.y);return false; }")

.Append("</Script>")

End With

RegisterStartupScript("ContextMenu", Script.ToString)

End Sub

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: C. Alexander | last post by:
I'm making a 'whiteboard' application. I'm trying to have 2+ connected users able to draw at the same time. However, if User1 draws a line, when User2 is drawing, on User1 screen, it will draw...
5
by: cexpert | last post by:
if i got no problem with createpopup() function to fill a popup window with HTML, i am unable to insert script popupBody.innerHTML="<scriptlanguage='javascript'></script>" gives me a " non-closed...
5
by: J | last post by:
Hi, I'm using the following code snippet to show popup menus (in a header frame) and target the menu options to another frame. This works fine for a single hard-coded frame (e.g. "2" below, in...
1
by: Martin John Brindle | last post by:
Is it possible to return a value from a popup window? I really need something that can do this and the behaviour of the createpopup method is perfect except i can't work out how to return a value....
2
by: Sergey Poberezovskiy | last post by:
Hi, I need to show a popup on my Web Page, so I write: var oPop = window.createPopup() oPop.show(x,y,W,H); I have a problem with W =width and H = height of the popup window: When a user...
1
by: Leoa | last post by:
Hi There, I made a popup window with createpopup(). The window has a frame border around it that is grey. I can't seem to find the code that would not allow the frame of the popup to show. ...
8
by: sivavenu | last post by:
Hi All, I am working on ASP.NET 2.0. In my code i have written window.createPopup() in Java Script but it is not working with firefox. Please provide me the alternative one to work with Firefox.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.