S
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.
*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/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">
<aspropDownList 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>
</aspropDownlist>
</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)
{
}
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/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">
<aspropDownList 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>
</aspropDownlist>
</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)
{
}