Error Message is not clear to me

If what you posted is your whole class, you’re missing a curly brace. Exactly as the error message says.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
    protected void gettickvalue(object sender, EventArgs e)
        Random RandomNumber = new Random();
        int n = RandomNumber.Next(1, 9);
        imgBanner.ImageUrl = String.Concat("Timer/banner_", n.ToString(), ".jpg");  
} //we added this curly brace

It’s easier to see where it’s missing if you format your code properly. Visual Studio can do this for you, look it up to see how in your version. I’m on Visual Studio 2010 Pro, so I go to Edit -> Advanced -> Format Document.

Notice also that I changed your concatenation function to just be String.Concat instead of System.String.Concat. No need to put the system reference in front of it because the namespace is already referenced by your first using statement.

I also suggest you rename your function. See General Naming Conventions on MSDN.

Leave a Comment