Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!LoginState.TestLogin())
        {
            return;
        }

        if (string.IsNullOrEmpty(RouteName.Value))
        {
            RouteName.Value = Request.Params["Route"];
        }

        string script = string.Format(@"
function getRouteName(){{
    return document.getElementById('{0}').value; 
}}
function getGpsField(){{
    return document.getElementById('{1}'); 
}}
function getUpdateImagesButton(){{
    return document.getElementById('{2}'); 
}}", RouteName.ClientID, TextBoxGPS.ClientID, ReloadImages.ClientID);

        ScriptManager.RegisterClientScriptBlock(
            this,
            GetType(),
            "ScriptFunctions",
            script,
            true);


        MapFrame.Attributes["src"]            = "map.aspx?EditMode=true&Route=" + RouteName.Value;
        MapFrame.Attributes["onload"]         = "frameLoaded(this);";
        UploadImageFrame.Attributes["src"]    = "UploadFile.aspx?Route=" + RouteName.Value;
        UploadImageFrame.Attributes["onload"] = "imagesUploaded(this);";
        route = DBHelper.GetRoute(RouteName.Value);

        if (!IsPostBack && route != null)
        {
            TextBoxTitle.Text         = route.Title;
            TextBoxDescription.Text   = route.Description;
            TextBoxCiclyng.Text       = route.Cycling.ToString();
            TextBoxDifficulty.Text    = route.Difficulty;
            CheckBoxPublished.Checked = !route.Draft;
            DifficultyFromString();
            mainImage = route.Image;
        }

        SetDifficulties(ClimbPanel);
        SetDifficulties(DownPanel);
        DifficultyToString();
        BuildImageControls();
    }
Example #2
0
 protected void Rank_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!LoginState.TestLogin())
     {
         return;
     }
     try
     {
         byte vote = Convert.ToByte(Rank.SelectedIndex + 1);
         DBHelper.SaveRank(LoginState.User.Id, GetRoute().Id, vote);
         RankMessage.Text = String.Format("Il tuo voto ({0}) è stato registrato, grazie per il contributo.", vote);
     }
     catch (Exception ex)
     {
         RankMessage.Text = String.Format("Si è verificato un errore: {0}", ex.Message);
     }
     RankMessage.Visible = true;
 }