Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Panel problem

Status
Not open for further replies.

Wiezewazoel

Programmer
Apr 4, 2008
10
BE
i don't know if it really belongs here but i think it does,

The problem is: (i'm making a 'time table' where u can see the progress of a project. Example: Example)

i have 2 update panels (upOuter and upInner).
In the outer one the user chooses a month and year with numericupdown extender

when this person does this, i would like the inner update panel to update his table if the month or year changes.

Don't worry about the table itself, i'm not there yet, i first want to try altering the table.

What it does now: it does change the table but it dissapears like after a second! or sometimes, it stays but not always... and also the browser sais i have an error :s

i have no idea why the table inside the inner Update panel just dissapears for no reason :(


Code:

THE .aspx page!
Code:
<%@ Page Language="C#" MasterPageFile="~/Masterpage/KronosMasterPage.master" AutoEventWireup="true" CodeFile="ToonVordering.aspx.cs" Inherits="Site_ToonVordering" Title="Untitled Page" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <asp:Label ID="lblWelkomBericht" runat="server"></asp:Label>
    <br />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <br />
    Kies een project:
    <asp:DropDownList ID="ddlProjecten" runat="server" AutoPostBack="True" 
        onselectedindexchanged="ddlProjecten_SelectedIndexChanged">
    </asp:DropDownList>
    <br />
    <br />
    <asp:Panel ID="pnlVordering" runat="server" Visible="False">
        <asp:UpdatePanel ID="upOuter" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <p>
                    <span class="LoginSpan">Kies een maand:</span>
                    <asp:ImageButton ID="btnLinksMaand" runat="server" ImageUrl="~/Images/Left.jpg" />
                    <asp:TextBox ID="txtMaand" runat="server" ontextchanged="TextChanged" AutoPostBack="true"></asp:TextBox>
                    <asp:ImageButton ID="brnRechtsMaand" runat="server" ImageUrl="~/Images/Right.jpg" />
                </p>
                <p>
                    <span class="LoginSpan">Kies een jaar:</span>
                    <asp:ImageButton ID="btnLinksJaar" runat="server" ImageUrl="~/Images/Left.jpg" />
                    <asp:TextBox ID="txtJaar" Text="2008" runat="server" ontextchanged="TextChanged" AutoPostBack="true"></asp:TextBox>   
                    <asp:ImageButton ID="btnRechtsJaar" runat="server" ImageUrl="~/Images/Right.jpg"/>
                </p>   
                
                <asp:UpdatePanel ID="upInner" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:Table ID="tblVordering" runat="server" Width="736px">
                        </asp:Table>
                    </ContentTemplate>
                </asp:UpdatePanel>       
                
                <cc1:NumericUpDownExtender ID="nudMaand" runat="server"
                    TargetControlID="txtMaand"
                    Width="120"
                    RefValues=""
                    ServiceUpPath=""
                    ServiceDownPath=""
                    ServiceUpMethod=""
                    ServiceDownMethod=""
                    TargetButtonUpID="brnRechtsMaand"
                    TargetButtonDownID="btnLinksMaand">
                </cc1:NumericUpDownExtender>
                           
                <cc1:NumericUpDownExtender ID="nudJaar" runat="server"
                    TargetControlID="txtJaar"
                    Width="120"
                    RefValues=""
                    ServiceUpPath=""
                    ServiceDownPath=""
                    ServiceUpMethod=""
                    ServiceDownMethod=""
                    TargetButtonUpID="btnRechtsJaar"
                    TargetButtonDownID="btnLinksJaar">
                </cc1:NumericUpDownExtender>
                
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <br />
    <asp:Label ID="lblFeedback" runat="server"></asp:Label>
    <br />

</asp:Content>

The .aspx.cs page

Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using KronosProject.Domain;
using System.Collections.Generic;
using System.Globalization;

public partial class Site_ToonVordering : System.Web.UI.Page
{
    #region Attributen

    private Medewerker _gebruiker = null;
    private Project _project = null;
    private int _maand = 0;
    private int _jaar = 0;

    #endregion

    #region Page Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.Master.Page.Header.Title = "KronosProject : Projectbeheer";
            _gebruiker = (Medewerker)Session["Gebruiker"];
            lblWelkomBericht.Text = "Welkom, " + _gebruiker.Famnaam + " " + _gebruiker.Voornaam;
            VulDDLProjecten();
            List<Vordering> vorderingen = ToonVorderingController.GetVorderingen(1);
        }
        else
        {
            if (Session["Project"] != null)
                _project = (Project)Session["Project"];
            if (Session["Maand"] != null)
                _maand = (int)Session["Maand"];
            if (Session["Jaar"] != null)
                _jaar = (int)Session["Jaar"];
        }
    }

    #endregion

    #region Methoden

    private void VulDDLProjecten()
    {
        try
        {
            ddlProjecten.DataSource = MaakPlanningController.GetProjecten(_gebruiker.ID);
            ddlProjecten.DataTextField = "naam";
            ddlProjecten.DataValueField = "ID";
            ddlProjecten.DataBind();
            ddlProjecten.Items.Insert(0, new ListItem("--Kies een project--", "0"));
        }
        catch (Exception ex)
        {
            lblFeedback.Text = ex.Message;
        }
    }

    protected void ddlProjecten_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            if (ddlProjecten.SelectedValue != "0")
            {
                pnlVordering.Visible = true;
                vulTextBox();
            }
        }
        catch (Exception ex)
        {
            lblFeedback.Text = ex.Message;
        }
    }

    private void vulTextBox()
    {
        nudMaand.RefValues = GetMaanden();
        txtMaand.Text = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month);
    }

    private void vulTabel()
    {
        
    }

    private String GetMaanden()
    {
        String maanden = "";
        for (int i = 1; i < 13; i++)
        {
            if (i > 0 && i < 12)
                maanden += CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i) + ";";
            else
                maanden += CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i);
        }
        return maanden;
    }

    #endregion
    protected void TextChanged(object sender, EventArgs e)
    {
        if(((TextBox)sender).ID == "txtMaand")
        {
            TableRow test = new TableRow();
            TableCell test2 = new TableCell();

            switch(txtMaand.Text)
            {
                case "januari": _maand = 1; break;
                case "februari": _maand = 2; break;
                case "maart": _maand = 3; break;
                case "april": _maand = 4; break;
                case "mei": _maand = 5; break;
                case "juni": _maand = 6; break;
                case "juli": _maand = 7; break;
                case "augustus": _maand = 8; break;
                case "september": _maand = 9; break;
                case "oktober": _maand = 10; break;
                case "november": _maand = 11; break;
                case "december": _maand = 12; break;
            }
            Session["Maand"] = _maand;
            test2.Text = "" + _maand;
            test2.ColumnSpan = 30;
            test.Cells.Add(test2);
            tblVordering.Rows.Add(test);
        }
    }
}

don't mind the dutch things, its just month and year, then i want to convert back to the number of the month

 
Now that i thought about it, this could also belong in the ASP forum, but i have no clue where my problem is so..i'm sorry if wrong forum
 
forum855 is dedicated to asp.net.
the problem is you are building the table dynamically. so you need to rebuild it with each postback.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
so it would be solved i i like put the table in a session for a while, right?

well I have tried it and that didn't do the trick somehow, it keeps showing the numer for like half a sec, then disappears
 
why do you have an update panel wrapped in an update panel. the inner UP doesn't have conditional rendering or triggers so there is no need for it.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
ah k, but even if i get it out, it still just shows 1 second then away again, even in session :s
 
nothing jumps out at me directly. I would remove all update panels and ajax controls. get the page working in full postback and then add one control toolkit item at a time.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top