Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DropDown Calender Control errorDropDown Calender Control error
Previous
 
Next
New Post
10/10/2006 11:44 AM
 

I am trying to create a dropdown calender control with DNN 4.34 but in my code i keep getting ambiguous errors. I am not sure how to change my code so they are not ambiguous. I can probably rename calendar and ui (maybe) but i don't know what to do with the Text.StringBuilder()

I am guessing I need to import some other DNN classes etc but not sure.

here are the errors i get below that is my code Thanks...

  • Error 1 'Text' is ambiguous, imported from the namespaces or types 'System.Drawing, System'.
  • Error 2 'Calendar' is ambiguous, imported from the namespaces or types 'System.Web.UI.WebControls, System.Globalization, DotNetNuke.Common.Utilities'. 
  • Error 3 'UI' is ambiguous, imported from the namespaces or types 'System.Web, DotNetNuke'. 

 

Imports Microsoft.VisualBasic

Namespace DDCalender

Module commonScript

Sub WritePopupRoutines(ByVal Page As System.Web.UI.Page)

Dim sb As New Text.StringBuilder()

sb = New StringBuilder

sb.AppendLine("var __popup_panel;")

sb.AppendLine("function __popup_clear() {")

sb.AppendLine(" if (__popup_panel != null ) ")

sb.AppendLine(" {")

sb.AppendLine(" document.getElementById(__popup_panel).style.display='none';")

sb.AppendLine(" __popup_panel=null;")

' sb.AppendLine(" document.onclick=null;")

sb.AppendLine(" }")

sb.AppendLine("}")

sb.AppendLine("function __popup_losefocus(panel)")

sb.AppendLine("{")

sb.AppendLine(" if (!panel.contains(document.activeElement))")

sb.AppendLine(" {")

sb.AppendLine(" panel.style.display='none';")

sb.AppendLine(" }")

sb.AppendLine("}")

Page.ClientScript.RegisterClientScriptBlock(Page.GetType, "PopupRoutines", sb.ToString, True)

End Sub

End Module

Public Class DatePicker

Inherits WebControl

Implements INamingContainer

Private _innerCal As Calendar

Private _innerTbx As TextBox

Private errorText As String = Nothing

Private _panelvisible As Boolean = False

Sub New()

MyBase.New(UI.HtmlTextWriterTag.Div)

End Sub

Public Property SelectedDate() As Date

Get

EnsureChildControls()

Dim d As Date

Try

d = Date.Parse(_innerTbx.Text)

errorText = Nothing

_innerCal.SelectedDate = d

Catch

errorText = "Date needs to be specified as mm/dd/yyyy"

End Try

Return d

End Get

Set(ByVal value As Date)

EnsureChildControls()

_innerCal.SelectedDate = value

_innerTbx.Text = value.ToShortDateString

End Set

End Property

Protected Overrides Sub CreateChildControls()

MyBase.CreateChildControls()

_innerTbx = New TextBox

Me.Controls.Add(_innerTbx)

_innerCal = New Calendar

AddHandler _innerCal.SelectionChanged, AddressOf _innerCal_SelectionChanged

AddHandler _innerCal.VisibleMonthChanged, AddressOf _innerCal_MonthChanged

Controls.Add(_innerCal)

End Sub

Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag

Get

Return HtmlTextWriterTag.Div

End Get

End Property

 

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)

If Me.Width.IsEmpty Then Me.Width = New Unit(150)

MyBase.AddAttributesToRender(writer)

End Sub

Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)

_innerTbx.Attributes.Add("Align", "AbsMiddle")

_innerTbx.Width = New Unit(100)

'_innerTbx.Height = New Unit(20)

_innerTbx.RenderControl(writer)

Dim innerid As String = Me.UniqueID & "_inner"

writer.AddAttribute("Align", "AbsMiddle")

writer.AddAttribute("src", "images/dropdownbtn.gif")

writer.AddAttribute("onClick", "__datepicker_showpopup('" & innerid & "')")

writer.RenderBeginTag(HtmlTextWriterTag.Img)

writer.RenderEndTag()

If errorText <> Nothing Then

writer.AddStyleAttribute("color", "red")

writer.AddStyleAttribute("display", "block")

writer.RenderBeginTag(HtmlTextWriterTag.Span)

writer.Write(errorText)

writer.RenderEndTag()

End If

 

writer.AddStyleAttribute("position", "relative")

writer.RenderBeginTag(HtmlTextWriterTag.Div)

 

writer.AddStyleAttribute("position", "absolute")

writer.AddStyleAttribute("left", "0px")

writer.AddStyleAttribute("top", "0px")

writer.AddStyleAttribute("z-index", "100")

Dim panelvisible As String

If _panelvisible Then panelvisible = "block" Else panelvisible = "none"

writer.AddStyleAttribute("display", panelvisible)

writer.AddStyleAttribute("background-color", "white")

writer.AddAttribute("id", innerid)

writer.AddAttribute("onfocusout", "__popup_losefocus(this)")

writer.RenderBeginTag(HtmlTextWriterTag.Div)

_innerCal.RenderControl(writer)

writer.RenderEndTag()

writer.RenderEndTag()

End Sub

Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)

MyBase.OnPreRender(e)

commonScript.WritePopupRoutines(Page)

Dim sb As New StringBuilder

If _panelvisible Then

sb.AppendLine("__popup_panel = '" & Me.UniqueID & "_inner';")

End If

sb.AppendLine("function __datepicker_showpopup(name)")

sb.AppendLine("{")

sb.AppendLine(" if (__popup_panel != null)")

sb.AppendLine(" {")

sb.AppendLine(" document.getElementById(__popup_panel).style.display='none';")

sb.AppendLine(" }")

sb.AppendLine(" __popup_panel=name;")

sb.AppendLine(" var panel=document.getElementById(__popup_panel);")

sb.AppendLine(" panel.style.display='block';")

sb.AppendLine(" var links=panel.getElementsByTagName('A');")

sb.AppendLine(" links[0].focus();")

' sb.AppendLine(" document.onclick=__popup_clear();")

sb.AppendLine(" window.event.cancelBubble=true;")

sb.AppendLine("}")

Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "popup", sb.ToString, True)

Page.MaintainScrollPositionOnPostBack = True

End Sub

 

Private Sub _innerCal_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)

EnsureChildControls()

_innerTbx.Text = _innerCal.SelectedDate.ToShortDateString

End Sub

'keep the panel for another

Private Sub _innerCal_MonthChanged(ByVal sender As Object, ByVal e As MonthChangedEventArgs)

_panelvisible = True

End Sub

End Class

End Namespace

 
New Post
10/10/2006 3:54 PM
 

The errors are telling you exactly what the problem is.  You have imported multiple namespaces.  When you simply call Text, Calendar or UI, your code realizes those classes exist in more than one namespace.  To fix this, all you need to do is explicitly tell your code which one you want to use.  I don't know enough about your application to tell you exactly which ones you need, but from a quick glance, I'm guessing you should be using:

  1. System.Text
  2. Webcontrols.Calendar
  3. Web.UI

 

 
New Post
10/11/2006 8:15 AM
 
That did it thanks!!
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0DropDown Calender Control errorDropDown Calender Control error


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out