Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 01:15
    Stephen
    0

    User control with drop list of Childnodes

    I feel I'm pretty close to getting this right but my drop down list wont display the child nodes of a specified node, it wont even display the "Please Select" items before the for next...anyone any ideas where i'm going wrong?

    Protected Sub Page_Load(sender As Object, e As EventArgs)
            If Not IsPostBack Then
                cboService.Items.Add(New ListItem("--- Please Select ---", ""))
                cboService.Items.Add(New ListItem("Other (Please detail in aditional info)", "Other"))
                Dim specificNode = New Node(1768)
                'Get the children as a Nodes collection
                Dim childNodes = specificNode.Children
                For Each childNode As Node In childNodes
                    cboService.Items.Add(New ListItem(childNode.Name, childNode.Id))
                Next
            End If
        End Sub

  • skiltz 501 posts 701 karma points
    Nov 29, 2011 @ 04:39
    skiltz
    0

    Updated your DLL?

  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 07:28
    Stephen
    0

    I have a post build script that copies the bin file and ascx file accross upon a successfull build, i've doubled checked this is happening, which it is.

    Its strange that its not even adding the "Please Select" item....just getting an empty drop down list.

    S

  • skiltz 501 posts 701 karma points
    Nov 29, 2011 @ 07:53
    skiltz
    0

    Everything ALWAYS has a reason so I doubt its "strange" :)  Can you post the full code behind and ascx page?

  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 07:59
    Stephen
    0
    Option Strict Off
    Option Explicit On
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  Page Title       :               '
    '  Description      : Quote form             ' 
    '  Author           : Stephen Davidson                  '
    '  Creation Date    : 16th August 2011                  '
    '  Version No       : 1                                 '
    '  Revision         :                                   '
    '  Revision Reason  :                              '
    '  Revisor          :                  '
    '  Date Revised     :                         '  
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Imports System
    Imports System.Web
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Web.UI.HtmlControls
    Imports System.Net
    Imports System.IO
    Imports System.Configuration
    Imports System.Net.Mail
    Imports Microsoft.VisualBasic
    Imports createsend_dotnet
    Imports System.Collections.Generic
    Imports umbraco.BusinessLogic
    Imports umbraco.cms.businesslogic.web
    Imports umbraco.presentation.masterpages
    Imports umbraco.ui
    Imports umbraco.interfaces
    Imports umbraco.cms
    Imports umbraco.presentation.nodeFactory
     
     
    Public Class gpQuote
        Inherits System.Web.UI.UserControl
     
        Protected Sub Page_Load(sender As Object, e As EventArgs)
            If Not IsPostBack Then
     
     
                cboService.Items.Add(New ListItem("--- Please Select ---", ""))
                cboService.Items.Add(New ListItem("Other (Please detail in aditional info)", "Other"))
     
                Dim specificNode = New Node(1788)
                'Get the children as a Nodes collection
                Dim childNodes = specificNode.Children
                For Each childNode As Node In childNodes
                    cboService.Items.Add(New ListItem(childNode.Name, childNode.Id))
     
                Next
     
                Dim sb As New StringBuilder()
     
                ' Get current page
                Dim currentPage As Node = Node.GetCurrent()
     
                ' Loop through all the children of the currentpage
                For Each page As Node In currentPage.Children
                    sb.Append([String].Format("{0} updated {1}<br />", page.Name, page.UpdateDate.ToShortDateString()))
                Next
     
                ' Update the literal
                nodeOutput.Text = sb.ToString()
     
     
     
     
            End If
        End Sub
     
        Protected Sub btnSubmit_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click
     
            Dim Result As Integer = 0
            'Updates and existing member
            Dim ContactTel As String = ""
            Dim Newsletter As String = ""
     
            If txtTel.Text = "" Then
                ContactTel = "None"
            Else
                ContactTel = txtTel.Text
            End If
            'Now we need to deal with the user communication settings
            'Dim apiKey As String = "0bfc35e57fe9eac0ebc26a3d5d4b7e11"
            'Dim listID As String = "5e6fa1410939f9a9d70c6383a38ec41e"
            'Dim subscriber As New Subscriber(listID)
            'Dim resultMessage As String = ""
            'Dim Name As String
            'Name = txtFirstname.Text & " " & txtSurname.Text
            'lets deal with Campaign monitor
            'If chkNewsletter.Checked Then
            'Newsletter = "Yes"
            'Try
            'Dim newSubscriberID As String = Subscriber.Add(txtEmail.Text, Name, Nothing, False)
            'Console.WriteLine(newSubscriberID)
            'Catch ex As CreatesendException
            'Dim [error] As ErrorResult = DirectCast(ex.Data("ErrorResult"), ErrorResult)
            'Console.WriteLine([error].Code)
            'Console.WriteLine([error].Message)
            'handle some other failure
            'Catch ex As Exception
            'litInfoErrorMessage.Text = "<p>We cannot communicate with Campaign Monitor, you're newsletter subscription has NOT been captured.<p>"
            'End Try
     
            'Else
            'Newsletter = "No"
            'End If
            'Now lets update umbraco so the client can view the enquiries
            Try
     
                'Get the type you would like to use by its alias 
                'and the user who should be the creator of the document 
                Dim dt As DocumentType = DocumentType.GetByAlias("gpQuoteResponse")
                Dim author As User = User.GetUser(0)
     
                'create a document with a name, a type, an umbraco user, and the ID of the document's parent page. 
                'To create a document at the root of umbraco, use the id -1 
     
                Dim doc As Document = Document.MakeNew("Response - " & txtFirstname.Text & " " & txtSurname.Text, dt, author, 1480)
                'Now enter the stuff we need to capture
                ' the value is saved in the database instantly!
                doc.getProperty("name").Value = txtFirstname.Text & " " & txtSurname.Text
                doc.getProperty("enquiryDate").Value = DateTime.Now
                doc.getProperty("contactTel").Value = txtTel.Text
                doc.getProperty("emailAddress").Value = txtEmail.Text
                doc.getProperty("enquiryDetails").Value = txtDetails.Text
     
     
                'after creating the document, prepare it for publishing 
                doc.Save()
                'doc.Publish(author)
     
                'Tell umbraco to publish the document
                'umbraco.library.UpdateDocumentCache(doc.Id)
            Catch ex As Exception
     
                panFeedbackSucess.Visible = False
                panFeedback.Visible = False
                litInfoErrorMessage.Text = "<p>Sorry there was an error we did not manage to capture your details to the database but they may have been sent by email.</p>"
     
     
            End Try
     
     
            'Now go do the emails..
            Try
     
                Dim MyMailer As New MailMessage
                Dim MySmtpClient As New SmtpClient()
                MyMailer = New MailMessage
     
                MyMailer.From = New MailAddress("www.glasgowplastering.co.uk", "[email protected]")
                MyMailer.To.Add(New MailAddress("Mick Geraghty", "[email protected]"))
                MyMailer.CC.Add(New MailAddress("Mick Geraghty", "[email protected]"))
                MyMailer.Bcc.Add(New MailAddress("Stephen Davidson", "[email protected]"))
                MyMailer.Subject = "Site quote enquiry"
                MyMailer.Body = "A site user has submitted site quote enquiry." & vbCrLf & vbCr & _
                "The details are set out below:" & vbCrLf & vbCr & _
                "Name: " & txtFirstname.Text & " " & txtSurname.Text & vbCrLf & _
                "Email Address: " & txtEmail.Text & vbCrLf & vbCrLf & _
                "Telephone: " & txtTel.Text & vbCrLf & vbCrLf & _
                "Selected Service: " & cboService.SelectedItem.Text & vbCrLf & _
                "Comments: " & txtDetails.Text & vbCrLf & _
                "Thank you," & vbCrLf & vbCr & _
                "www.glasgowplastering.co.uk"
                MySmtpClient.Send(MyMailer)
                panFeedbackSucess.Visible = True
                panFeedback.Visible = False
            Catch
     
                panFeedbackSucess.Visible = False
                panFeedback.Visible = False
                litInfoErrorMessage.Text = "<p>Sorry there was an error with your mail to us, we were unable to send the comments.</p>"
            End Try
     
     
        End Sub
     
    End Class
     
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="gpQuote.ascx.vb" Inherits="umbracoUserControls.gpQuote" %>
    <div class="contactformWrapper">
    <div class="contactform">
    <asp:Literal ID="litInfoErrorMessage" runat="server" />
    <asp:Panel ID="panFeedback" runat="server">
    <p>Enter you details for a free no obligation quote and click the submit button. Items marked with a * are required.</p>
              <p><label>* First name: </label>
              <asp:TextBox ID="txtFirstname" runat="server" />
                  <br />
              <asp:RequiredFieldValidator ID="rfvFirstname" runat="server" ErrorMessage="Please enter your first name" ControlToValidate="txtFirstname" Display="Dynamic" ValidationGroup="feedback" />
              </p>
                <p><label>* Surname: </label>
                <asp:TextBox ID="txtSurname" runat="server" />
                    <br />
                <asp:RequiredFieldValidator ID="rfvSurname" runat="server" ErrorMessage="Please enter your surname" ControlToValidate="txtSurname" Display="Dynamic" ValidationGroup="feedback" />
                </p>
                <p><label>Contact Tel: </label>
                <asp:TextBox ID="txtTel" runat="server" />
                </p>
                <p><label>* Email Address: </label>
                <asp:TextBox ID="txtEmail" runat="server" Columns="40" />
                    <br />
                <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ErrorMessage="Please enter your Email Address" ControlToValidate="txtEmail" Display="Dynamic" ValidationGroup="feedback" />
                </p>
                <p>
               <label>Output:</label> <asp:Literal ID="nodeOutput" runat="server"></asp:Literal>
                </p>
                <p>
                    <label>* Service Required:</label>
                    <asp:DropDownList ID="cboService" runat="server" />
                </p>
                <p><label>* Enquiry details: </label>
                <asp:TextBox ID="txtDetails" runat="server" TextMode="MultiLine" Columns="30" Height="70" />
                    <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter your enquiry details" ControlToValidate="txtDetails" Display="Dynamic" ValidationGroup="feedback" />
    
                </p>
    
      <p>
          <asp:ImageButton ID="btnSubmit" runat="server" ImageAlign="Right" ImageUrl="/images/btnSubmit.png" ValidationGroup="feedback" /></p>
      </asp:Panel>
      <asp:Panel ID="panFeedbackSucess" runat="server" Visible="false">
      <h2>Thank you for your enquiry</h2>
      <p>If you're enquiry requires a response we aim to respond within 72 hours.  If you're enquiry requires our attenion sooner why not get in touch using the contact telelphone number opposite.</p>
          <p>
              Many thanks,</p>
          <p>
              MG Plastering</p>
      </asp:Panel>
          <br class="clearfloat" />
        </div>
    </div>
  • skiltz 501 posts 701 karma points
    Nov 29, 2011 @ 08:31
    skiltz
    0

    That actually looks fine to me.  Try a rebuild instead of a build... triple check the DLL is being updated.  Make sure you are referencing the right usercontrol in umbraco.  Create a new macro in umbraco and see if that helps.

  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 08:49
    Stephen
    0

    thanks Skiltz, appreciate your input, I'll go try what you suggested and report back,

    S

  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 09:03
    Stephen
    0

    Ok checked everything and still the same result.  I'm now going to try and use one of the examples from umrbaco TV to see if that works....

    S

  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 09:29
    Stephen
    0

    it gets stranger...i managed to get the control working using the sample from umbraco but its in C#, so i converted the code to VB to let me do my other stuff and it no longer works....wtf am I doing wrong?

    S

  • Stephen 204 posts 246 karma points
    Nov 29, 2011 @ 09:53
    Stephen
    0

    Jez...i got it at last...all to do with the page load...

    i had

    ProtectedSubPage_Load(sender AsObject, e AsEventArgs)

    and  it should be

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    dont know how the feck i missed it but at least i've confirmed that I'm not officially mental!

    Thanks again..

    S

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Nov 29, 2011 @ 11:02
    Jeroen Breuer
    0

    Hello,

    Nice to see it's fixed. If you want to databind children here might be some useful examples: http://our.umbraco.org/wiki/reference/code-snippets/databind-node-children.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft