471,605 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,605 software developers and data experts.

problems with AutoPostBack

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.

*Note: this is using Visual Studio 2005 std. and .NET 2.0*

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

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/ReportSchedule...geReports.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_SelectedNodeC hanged">
</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_Sele ctedIndexChanged">
<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)
{

}

Jan 20 '06 #1
2 2023
Sean,

Can you post the full ASPX and CS files?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sean Chapman" <se**********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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.

*Note: this is using Visual Studio 2005 std. and .NET 2.0*

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

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/ReportSchedule...geReports.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_SelectedNodeC hanged">
</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_Sele ctedIndexChanged">
<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)
{

}

Jan 21 '06 #2
That was most of it.. but here's the full copy/past for the markup/code
behind:
MARKUP:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="ManageReports.aspx.cs" Inherits="ManageReports" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Manage Report Schedule</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Table runat=server ID="contentTable" >
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server"
ID="userLabel"></asp:Label>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell VerticalAlign="Top">
<asp:TreeView runat=server ID="reportListing"
OnSelectedNodeChanged="reportListing_SelectedNodeC hanged">
</asp:TreeView>
</asp:TableCell>
<asp:TableCell VerticalAlign="Top">

</asp:TableCell>
<asp:TableCell VerticalAlign="Top">
<asp:DropDownList runat="server"
ID="frequencyListDropDown" AutoPostBack="true"
OnSelectedIndexChanged="frequencyListDropDown_Sele ctedIndexChanged">
<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>
</body>
</html>

CODEBEHIND:

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 System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;

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"));
userLabel.Text = (string)Session["user"];
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)
{

}
}

thanks for any input.

Jan 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tomas Vera | last post: by
3 posts views Thread by TCORDON | last post: by
6 posts views Thread by tfsmag | last post: by
2 posts views Thread by tshad | last post: by
reply views Thread by riley.derrick | last post: by
reply views Thread by Mark Sandfox | last post: by
6 posts views Thread by Peter | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.