Attribute being escaped

C

CJ Taylor

Hey Everyone,

I'm trying to add a javascript popup function to my site so I just make one
function call... here is the function (feel free to use it if you want as
well)

Public Shared Function BuildPopup(ByRef pControl As WebControl, _

ByVal pTarget As String, _

ByVal pWidth As Integer, _

ByVal pHeight As Integer, _

Optional ByVal pWindowName As String = "popup", _

Optional ByVal pParameters As Collections.Specialized.NameValueCollection =
Nothing, _

Optional ByVal pShowScrollbars As Boolean = False, _

Optional ByVal pAllowResize As Boolean = True, _

Optional ByVal pToolbar As Boolean = False, _

Optional ByVal pLocation As Boolean = False, _

Optional ByVal pMenubar As Boolean = False, _

Optional ByVal [Event] As String = "onclick")



Dim oOpenString As String

Dim oParameter As String

Dim iCount As Integer = 0

oOpenString = "javascript:window.open('" & pTarget

'add parameters

If Not pParameters Is Nothing Then

For Each oParameter In pParameters.Keys

If iCount = 0 Then

oOpenString += "?"

Else

oOpenString += "&"

End If

oOpenString += oParameter & "="

oOpenString += pControl.Page.Server.HtmlEncode(pParameters(oParameter))

iCount += 1

Next

End If

oOpenString += "','" & pWindowName & "','"

'build the features

oOpenString += "width=" & pWidth & ",height=" & pHeight

oOpenString += "," & IIf(pShowScrollbars, "scrollbars=yes", "scrollbars=no")

oOpenString += "," & IIf(pAllowResize, "resize=yes", "resize=no")

oOpenString += "," & IIf(pMenubar, "menubar=yes", "menubar=no")

oOpenString += "," & IIf(pToolbar, "toolbar=yes", "toolbar=no")

oOpenString += "," & IIf(pLocation, "location=yes", "location=no")

oOpenString += "');"

pControl.Attributes.Add([Event], oOpenString)



-------------------------



the problem is... when it renders.. the Parameters are being added correctly
however when its rendered the & for the variable split is coming out &

such that

javascript:window.open(targetpage.aspx?var1=1&=3 ...



How would I fix this?



Thanks

CJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top