Copied to clipboard

Flag this post as spam?

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


  • Bob McLane 19 posts 39 karma points
    Dec 09, 2010 @ 16:29
    Bob McLane
    0

    Parameters not being passed to .NET User Control

    I'm new to Umbraco and I'm working on adding my first .NET User Control (VB.NET/VS2008) to Umbraco 4.5.2

    • I've built the user control and moved the DLL to the umbraco bin folder and the control files to the umbraco user control folders.
    • I can see the control under the Macros node in the Developer section of Umbraco.
    • I can create a macro out of my control via the developer section.
    • I've checked "Use in editor" and "Render content in Editor"
    • When I browse properties I see my two properties and am able to add them as parameters for the macro.
    • I have a content page with a rich text editor. I click on insert macro. I choose my macro and am prompted for the values of my two parameters. I then save and publish the page.

    Here's where the problem starts ....

    I open the page up and I can see some of my control working but it's throwing an error because nothing is being passed to it through either parameter. If I hard code the values for the parameters inside the user control code everything works fine.  

    Below is my user control code. Does anyone see what I'm doing wrong? Is there something else I need to configure in Umbraco? Thanks for any help!

    Imports

     

    System.Xml

    Imports

     

    System.ServiceModel.Syndication

    Partial

     

    Public Class RPC_RSS_Parser

     

    Inherits System.Web.UI.UserControl

     

    Private m_sURL As String = ""

     

    Private m_sNavigationType As String = ""

     

    Private m_sError As String = ""

     

    Public Property RssURL() As String

     

    Get

     

    Return m_sURL

     

    End Get

     

    Set(ByVal value As String)

     

    Me.m_sURL = RssURL

     

    End Set

     

    End Property

     

    Public Property NavigationType() As String

     

    Get

     

    Return m_sNavigationType

     

    End Get

     

    Set(ByVal value As String)

     

    Me.m_sNavigationType = NavigationType

     

    End Set

     

    End Property

     

    Public ReadOnly Property SlideError() As String

     

    Get

     

    Return m_sError

     

    End Get

     

    End Property

     

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

     

    Try

     

    'Go out and get the feed

     

    'Cat Rental Equipment

     

    'used for debugging only

     

    Me.LiteralDebug.Text = "The URL passed in is: " & Me.m_sURL.ToString & " : the nav type was set to: " & Me.m_sNavigationType.ToString

     

    'Hard coded value for testing

     

    'Me.m_sURL = "http://blog.ringpower.com/syndication.axd?category=e81c5eca-d4b1-4121-9f91-4ebda7131047"

     

    'Here's where the errors being thrown ......

     

    Dim myFeed As SyndicationFeed = SyndicationFeed.Load(XmlReader.Create(Me.m_sURL.ToString))

     

    'For each post build a new slide for the slidedeck - assign to literal control

     

    Dim sSlide As New StringBuilder

     

    For Each BlogPost As SyndicationItem In myFeed.Items

    Debug.Print(BlogPost.Title.Text)

     

    'Build HTML

    sSlide.Append(

    "<dt>" & BlogPost.Title.Text & "</dt>")

    sSlide.Append(

    "<dd class='slide'><div class='sd-node sd-node-container'><div class='sd-node sd-node-content'><div class='sd-node sd-node-title'>")

    sSlide.Append(

    "<a href='#' target='_blank'>" & BlogPost.Title.Text & "</a></div>")

    sSlide.Append(

    "<div class='sd-node sd-node-date'>" & BlogPost.PublishDate.Date.ToShortDateString & "</div>")

    sSlide.Append(

    "<div class='sd-node sd-node-timesince'> Posted On: " & BlogPost.PublishDate.Date.ToShortDateString & "</div>")

    sSlide.Append(

    "<div class='sd-node sd-node-excerpt'><p>" & BlogPost.Summary.Text.ToString & "</p></div>")

    sSlide.Append(

    "<div class='sd-node sd-node-permalink'><a href='" & BlogPost.Id & "' target='_blank'>Read More</a></div></div></div></dd>")

     

    Next

     

    Me.LiteralMySlideDeck.Text = sSlide.ToString

     

    'Parameter passed in from Umbraco and using this literal control to select the navigation type

     

    Select Case Me.m_sNavigationType.ToUpper

     

    Case "TITLE"

     

    Me.LiteralNavType.Text = "<ul class='sd-node sd-node-nav sd-node-nav-primary sd-node-navigation-type-post-titles'></ul>"

     

    Case "DOTS"

     

    'Me.LiteralNavType.Text = "<ul class='sd-node sd-node-nav sd-node-nav-primary sd-node-navigation-type-simple-dots'></ul>"

     

    Case Else

     

    Me.LiteralNavType.Text = "<ul class='sd-node sd-node-nav sd-node-nav-primary sd-node-navigation-type-post-titles'></ul>"

     

    End Select

     

    Catch ex As Exception

     

    Me.m_sError = "RPC Slider User Control Error: " & ex.Message.ToString

     

    Me.LiteralMySlideDeck.Text = "RPC Slider User Control Error: " & ex.Message.ToString

     

    End Try

     

    End Sub

    End

     

    Class

     

    Here's the page html

    <%

    @ Control Language="vb" AutoEventWireup="false" CodeBehind="RPC_RSS_Parser.ascx.vb" Inherits="RSS_Parser.RPC_RSS_Parser" %>

    <

     

    script type="text/javascript" src='<%=Page.ResolveUrl("~/Scripts/jquery-1.4.4.min.js")%>'></script>

    <

     

    link rel="stylesheet" type="text/css" href="css/skin.css" media="screen,handheld" />

    <

     

    script type="text/javascript" src='<%=Page.ResolveUrl("~/Scripts/slidedeck.jquery.lite.pack.js")%>'></script>

    <

     

    div class="slidedeck_frame skin-light">

     

    <dl class="slidedeck" id="smart_slidedeck">

     

    <asp:Literal ID="LiteralMySlideDeck" runat="server"></asp:Literal>

     

    </dl>

     

    <a class="sd-node sd-node-nav-link sd-node-previous" href="#previous" target="_blank">Previous</a><a class="sd-node sd-node-nav-link sd-node-next" href="#next" target="_blank">Next</a>

     

    <asp:Literal ID="LiteralNavType" runat="server"></asp:Literal>

     

    </div>

     

    <script type="text/javascript">jQuery( '#smart_slidedeck' ).css({width:'960px',height:'370px'}).slidedeck( {"speed":500,"start":1,"autoPlay":true,"autoPlayInterval":5000,"cycle":true,"hideSpines":true} );</script>

     

    <script type="text/javascript" src='<%=Page.ResolveUrl("~/Scripts/skin.js")%>'></script>

    <

     

    asp:Literal ID="LiteralSlideDeckControl" runat="server"></asp:Literal>

    <

     

    asp:Literal ID="LiteralDebug" runat="server"></asp:Literal>

  • Thomas Stock 40 posts 70 karma points
    Dec 10, 2010 @ 09:52
    Thomas Stock
    0

    Hello,

    Set(ByVal value As String)
    Me.m_sURL = RssURL
    End Set


    should be:

    Set(ByVal value As String)
    Me.m_sURL = value
    End Set


    Same for the other property.
    It's one of those things u can spend hours debugging on. :-)

  • Bob McLane 19 posts 39 karma points
    Dec 10, 2010 @ 13:53
    Bob McLane
    0

    I'm a total idiot! Can't believe I missed that. Thanks for the fresh pair of eyes!

Please Sign in or register to post replies

Write your reply to:

Draft