Home All Groups Group Topic Archive Search About

Problem with autopostback on webcontrols

Author
20 Jan 2006 11:58 PM
Sean Chapman
I've got a simple page I've made with a few controls (Treeview,
Dropdownlist, ..). I'm running into an issue with autopostback. If I
set it to AutoPostBack = "True", when the event should fire I get a
Javascript error in IE.

If I don't set it, and let a button click do the postback, the event
fires normally.

*note: using visual studio 2005 + dotnet 2.0

Any help would be greatly appreciated.

IE Error:
Line: 34
Char: 9
Error: Object doesn't support this property or method.
Code: 0
URL: http://localhost:4022/ReportScheduler/ManageReports.aspx

markup:
<form id="form1" runat="server">
        <asp:Table runat=server ID="contentTable" >
            <asp:TableRow>
                <asp:TableCell VerticalAlign="Top">
                    <asp:TreeView runat=server ID="reportListing"
OnSelectedNodeChanged="reportListing_SelectedNodeChanged">
                    </asp:TreeView>
                </asp:TableCell>
                <asp:TableCell VerticalAlign="Top">
                    <asp:GridView runat=server ID="reportDetails">

                    </asp:GridView>
                </asp:TableCell>
                <asp:TableCell VerticalAlign="Top">
                    <asp:DropDownList runat="server"
ID="frequencyListDropDown"  AutoPostBack="true"
OnSelectedIndexChanged="frequencyListDropDown_SelectedIndexChanged">
                         <asp:ListItem
Selected=True>Daily</asp:ListItem>
                         <asp:ListItem>Weekly</asp:ListItem>
                         <asp:ListItem>Middle And End Of
Month</asp:ListItem>
                         <asp:ListItem>Monthly</asp:ListItem>
                    </asp:DropDownlist>
                </asp:TableCell>
                <asp:TableCell VerticalAlign="Top">
                    <asp:CheckBoxList runat=server ID="daysOfWeek"
RepeatDirection="Horizontal" Visible=false>
                        <asp:ListItem>Sunday</asp:ListItem>
                        <asp:ListItem>Monday</asp:ListItem>
                        <asp:ListItem>Tuesday</asp:ListItem>
                        <asp:ListItem>Wednesday</asp:ListItem>
                        <asp:ListItem>Thursday</asp:ListItem>
                        <asp:ListItem>Friday</asp:ListItem>
                        <asp:ListItem>Saturday</asp:ListItem>
                    </asp:CheckBoxList>
                    <asp:Calendar runat=server ID="monthDaySelect"
Visible=false></asp:Calendar>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell></asp:TableCell>
                <asp:TableCell></asp:TableCell>
                <asp:TableCell>
                    <asp:Button runat=server ID="submit"
OnClick="submit_click" Text="Submit" />
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </form>

Codebehind:

public partial class ManageReports : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack) //set up initial page
        {

            System.Data.DataSet reportList = new DataSet();
            reportList.ReadXml(Server.MapPath("Reports.xml"));
            foreach (DataTable t in reportList.Tables)
            {
                foreach (DataRow dr in t.Rows)
                {
                    TreeNode parentNode = new TreeNode();
                    parentNode.Text = dr.Table.TableName;
                    reportListing.Nodes.Add(parentNode);
                    foreach (string innerRow in dr.ItemArray)
                    {
                        parentNode.ChildNodes.Add(new
TreeNode(innerRow));
                    }
                }
            }
        }
    }

    protected void frequencyListDropDown_SelectedIndexChanged(object
sender, EventArgs e)
    {
        //if (IsPostBack)
        {
            if (frequencyListDropDown.SelectedValue == "Monthly")
            {
                daysOfWeek.Visible = false;
                monthDaySelect.Visible = true;

            }
            else if (frequencyListDropDown.SelectedValue == "Weekly")
            {
                daysOfWeek.Visible = true;
                monthDaySelect.Visible = false;
            }
            else if ((frequencyListDropDown.SelectedValue == "Daily")
|| (frequencyListDropDown.SelectedValue == "Middle And End Of Month"))
            {
                daysOfWeek.Visible = false;
                monthDaySelect.Visible = false;
            }
        }
    }

    protected void submit_click(object sender, EventArgs e)
    {

    }

    protected void reportListing_SelectedNodeChanged(object sender,
EventArgs e)
    {

    }

Author
21 Jan 2006 3:22 AM
EJD
Sean,
I would suggest looking at the following article as it has helped me a
great deal.  I don't know if this applies to ASP.Net 2.0 because I
haven't tried it ***yet***, but it works well in the earlier
version(s).
http://devcenter.infragistics.com/Articles/ArticleTemplate.Aspx?ArticleID=2183
Granted, it's hard to tell what is going wrong without seeing a view
source on the page, but it seems likely that one or more of the
"OnSelectedIndexChanged" or "On...Node" could be funky.  And you've
probably already done this, but just in case you haven't, do a view
source on the page and check out what's in the neighborhood of "line
34."
HTH, and good luck.
Eric

AddThis Social Bookmark Button