Copied to clipboard

Flag this post as spam?

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


  • pikej 27 posts 47 karma points
    Jan 29, 2011 @ 21:16
    pikej
    0

    passing value to macro

    hi guys,

    I try to pass a value to macro that is built on web user control ascx. For some reason it is not working, I use: 

    <umbraco:Macro Alias="userControl" "downloadUrl=http://google.com" runat="server"></umbraco:Macro>

    and the bit of the code in ascx.cx is:

     protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

                Session["time"] = DateTime.Now.AddSeconds(10);

            }

        }

        public string downloadUrl {

            get { return (String)Session["downloadUrl"];  }

            set {Session["downloadUrl"] = value;}

        }

        protected void Timer1_Tick(object sender, EventArgs e)

        {

            TimeSpan time1 = new TimeSpan();        

            time1 = (DateTime)Session["time"] - DateTime.Now;

            if (time1.Seconds <= 0)

            {

                   Response.Redirect(downloadUrl);

            }

            else

            {

                Label1.Text = "wait " + time1.Seconds.ToString() + " seconds.";

            }

        }

    I also added downloadUrl parameter in macro (as text).
    Why it doesn't work?
    thanks in advance

  • Lars Skjoldby 11 posts 29 karma points
    Jan 29, 2011 @ 23:54
    Lars Skjoldby
    0

    I'm having a similar problem. I narrowed it down to the forward slashes in the parameter value. I've tried to escape it with both // and \/ both it doesn't seem to have an effect.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 30, 2011 @ 00:31
    Jan Skovgaard
    0

    Hi Guys

    How are your developlment setup? Do you copy the user control and the files in the bin folder manually or are you using xcopy to do this when you're building?

    Have you remembered to copy the .dll file in the bin folder into the folder as well?

    Is the reference to the user control in the macro setup properly?

    /Jan

  • pikej 27 posts 47 karma points
    Jan 30, 2011 @ 01:56
    pikej
    0

    hi Jan,

    I didn't do dll file but after your reply I tried to add it an  I think it is there (I put them via ftp into umbraco files).

    The difference now is that when I add macro it actually asks me for the value of downloadUrl. So there is a slow progress, but the whole thing still doesn't work.

    Maybe I do it all wrong, all I want to achieve is a page that waits a few seconds before redirecting to a download file. I have all the code in aspx but cannot implement it to umbraco :( . Maybe you have another idea, how to postpone a page from loading for a few seconds in umbraco?

    I will have another go tomorrow morning and let you know.

    all the best,

    pikej 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 30, 2011 @ 09:25
    Jan Skovgaard
    0

    Hi Pikej

    Maybe you can benefit from watching some of the free videos on creating user controls here: http://umbraco.tv/products/umbracotv

    Have a look at Using .NET user controls and Macro parameters.

    Hope this helps.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft