D
Daniel Walzenbach
Hi,
I created the following custom control to open a form in a new window. All this control does is to write a JavaScript link. Additionally I'd like to react on a MouseClick made on the control. How can I do this?
' This is the control by now...
' ***********************************************************************
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Text
Imports System.Web.UI.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}
opUpWindow runat=server></{0}
opUpWindow>")> Public Class PopUpWindow
Inherits System.Web.UI.WebControls.WebControl
Public EditMode As Boolean = False
Public Scrollbars As Boolean = False
Public Menubar As Boolean = False
Public Modal As Boolean = False
Public Locationbar As Boolean = False
Public Resizable As Boolean = False
Public Statusbar As Boolean = False
Public Fullscreen As Boolean = False
Public Top As Unit = New Unit()
Public Left As Unit = New Unit()
Public Text As String = ""
Public ImageUrl As String = ""
Public AlternateText As String = ""
'**********************navigate url als proproperty***********************
<Bindable(True), Category("Appearance"), DefaultValue("")> Property NavigateUrl() As String
Get
Dim _obj As Object = viewstate("NavigateUrl")
If _obj Is System.DBNull.Value Then
Return String.Empty
Else
Return _obj.ToString
End If
End Get
Set(ByVal Value As String)
viewstate("NavigateUrl") = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
If ImageUrl <> String.Empty Then
Text = "<img src='" + ImageUrl + "' alt='" + AlternateText + "' border='0'>" + Text
End If
output.Write("<a href='javascript
opUp_" + Me.ClientID + "()'>" + Text + "</a>")
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
'********hier string fuer options bauen***************************
Dim options As StringBuilder = New StringBuilder()
Dim myString As StringBuilder = New StringBuilder("<script language='javascript'>")
If Fullscreen Then
options.Append("Fullscreen=yes, ")
Else
options.Append("Fullscreen=no, ")
End If
If Scrollbars Then
options.Append("Scrollbars=yes, ")
Else
options.Append("Scrollbars=no, ")
End If
If Menubar Then
options.Append("Menubar=yes, ")
Else
options.Append("Menubar=no, ")
End If
If Locationbar Then
options.Append("Locationbar=yes, ")
Else
options.Append("Locationbar=no, ")
End If
If Resizable Then
options.Append("Resizable=yes, ")
Else
options.Append("Resizable=no, ")
End If
If Statusbar Then
options.Append("Status=yes ")
Else
options.Append("Status=no ")
End If
If Not Left.IsEmpty Then
options.Append("left=" + Left.ToString + ", ")
End If
If Not Top.IsEmpty Then
options.Append("top=" + Top.ToString + ", ")
End If
If Not Width.IsEmpty Then
options.Append("width=" + Width.ToString + ", ")
End If
If Not Height.IsEmpty Then
options.Append("height=" + Height.ToString)
End If
myString.Append("function PopUp_" + Me.ClientID + "(){")
If Modal Then
myString.Append(" window.showModalDialog('" + viewstate("NavigateUrl") + "','','" + options.ToString + "')")
Else
myString.Append(" window.open('" + viewstate("NavigateUrl") + "','','" + options.ToString + "')")
End If
myString.Append("}</script")
myString.Append(">")
Page.RegisterClientScriptBlock("PopUp_" + Me.ClientID, myString.ToString)
End Sub
End Class
Thanks a lot for your help.
Best regards
Daniel Walzenbach
P.S. If you need to contact me simply remove ".NOSPAM" from my email address.
I created the following custom control to open a form in a new window. All this control does is to write a JavaScript link. Additionally I'd like to react on a MouseClick made on the control. How can I do this?
' This is the control by now...
' ***********************************************************************
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Text
Imports System.Web.UI.WebControls
<DefaultProperty("Text"), ToolboxData("<{0}
Inherits System.Web.UI.WebControls.WebControl
Public EditMode As Boolean = False
Public Scrollbars As Boolean = False
Public Menubar As Boolean = False
Public Modal As Boolean = False
Public Locationbar As Boolean = False
Public Resizable As Boolean = False
Public Statusbar As Boolean = False
Public Fullscreen As Boolean = False
Public Top As Unit = New Unit()
Public Left As Unit = New Unit()
Public Text As String = ""
Public ImageUrl As String = ""
Public AlternateText As String = ""
'**********************navigate url als proproperty***********************
<Bindable(True), Category("Appearance"), DefaultValue("")> Property NavigateUrl() As String
Get
Dim _obj As Object = viewstate("NavigateUrl")
If _obj Is System.DBNull.Value Then
Return String.Empty
Else
Return _obj.ToString
End If
End Get
Set(ByVal Value As String)
viewstate("NavigateUrl") = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
If ImageUrl <> String.Empty Then
Text = "<img src='" + ImageUrl + "' alt='" + AlternateText + "' border='0'>" + Text
End If
output.Write("<a href='javascript
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
'********hier string fuer options bauen***************************
Dim options As StringBuilder = New StringBuilder()
Dim myString As StringBuilder = New StringBuilder("<script language='javascript'>")
If Fullscreen Then
options.Append("Fullscreen=yes, ")
Else
options.Append("Fullscreen=no, ")
End If
If Scrollbars Then
options.Append("Scrollbars=yes, ")
Else
options.Append("Scrollbars=no, ")
End If
If Menubar Then
options.Append("Menubar=yes, ")
Else
options.Append("Menubar=no, ")
End If
If Locationbar Then
options.Append("Locationbar=yes, ")
Else
options.Append("Locationbar=no, ")
End If
If Resizable Then
options.Append("Resizable=yes, ")
Else
options.Append("Resizable=no, ")
End If
If Statusbar Then
options.Append("Status=yes ")
Else
options.Append("Status=no ")
End If
If Not Left.IsEmpty Then
options.Append("left=" + Left.ToString + ", ")
End If
If Not Top.IsEmpty Then
options.Append("top=" + Top.ToString + ", ")
End If
If Not Width.IsEmpty Then
options.Append("width=" + Width.ToString + ", ")
End If
If Not Height.IsEmpty Then
options.Append("height=" + Height.ToString)
End If
myString.Append("function PopUp_" + Me.ClientID + "(){")
If Modal Then
myString.Append(" window.showModalDialog('" + viewstate("NavigateUrl") + "','','" + options.ToString + "')")
Else
myString.Append(" window.open('" + viewstate("NavigateUrl") + "','','" + options.ToString + "')")
End If
myString.Append("}</script")
myString.Append(">")
Page.RegisterClientScriptBlock("PopUp_" + Me.ClientID, myString.ToString)
End Sub
End Class
Thanks a lot for your help.
Best regards
Daniel Walzenbach
P.S. If you need to contact me simply remove ".NOSPAM" from my email address.