J
jediknight
I have a simple project where there is a master page called
MasterPage.master and some webforms which are content pages. I also
have a usercontrol which is a simple calendar control popup.
The folder structure is as follows:
Test Folder
Test.aspx (normal webform)
Test2.aspx (content page)
ctlCalendar.ascx
Default.aspx (normal webform)
Default2.aspx (content page)
MasterPage.master
Web.Config
Both Test.apsx and Test2.aspx use the calendar control.
Default.aspx redirects to Test.aspx and Default2.aspx redirect to
Test2.aspx.
The problem I'm having is that when I set Default.aspx as the startup
page, the calendar control works fine.
When I use Default2.aspx (content page) as the start up I get an error
Error: 'CtlCalendar1_pnlCalendar' is undefined
in the explorer status bar.
ctlCalendar Code is as follows:
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
this.TextBox1.Text = System.DateTime.Now.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION:
absolute");
}
else
{
string id =
Page.Request.Form["__EVENTTARGET"].Substring(0,Page.Request.Form["__EVENTTARGET"].IndexOf(":"));
if (id != this.ID)
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION:
absolute");
else
this.pnlCalendar.Attributes.Add("style","POSITION: absolute");
}
Page.RegisterClientScriptBlock("Script_Panel" + this.ID, "<script>
function On"+this.ID+"Click() { if("+this.ID
+"_pnlCalendar.style.display == \"none\") "+this.ID
+"_pnlCalendar.style.display = \"\"; else "+this.ID
+"_pnlCalendar.style.display = \"none\"; } </script>");
this.Button1.Attributes.Add("OnClick","On"+this.ID+"Click()");
}
private void Calendar1_SelectionChanged(object sender,
System.EventArgs e)
{
this.TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION:
absolute");
}
MasterPage.master and some webforms which are content pages. I also
have a usercontrol which is a simple calendar control popup.
The folder structure is as follows:
Test Folder
Test.aspx (normal webform)
Test2.aspx (content page)
ctlCalendar.ascx
Default.aspx (normal webform)
Default2.aspx (content page)
MasterPage.master
Web.Config
Both Test.apsx and Test2.aspx use the calendar control.
Default.aspx redirects to Test.aspx and Default2.aspx redirect to
Test2.aspx.
The problem I'm having is that when I set Default.aspx as the startup
page, the calendar control works fine.
When I use Default2.aspx (content page) as the start up I get an error
Error: 'CtlCalendar1_pnlCalendar' is undefined
in the explorer status bar.
ctlCalendar Code is as follows:
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
this.TextBox1.Text = System.DateTime.Now.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION:
absolute");
}
else
{
string id =
Page.Request.Form["__EVENTTARGET"].Substring(0,Page.Request.Form["__EVENTTARGET"].IndexOf(":"));
if (id != this.ID)
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION:
absolute");
else
this.pnlCalendar.Attributes.Add("style","POSITION: absolute");
}
Page.RegisterClientScriptBlock("Script_Panel" + this.ID, "<script>
function On"+this.ID+"Click() { if("+this.ID
+"_pnlCalendar.style.display == \"none\") "+this.ID
+"_pnlCalendar.style.display = \"\"; else "+this.ID
+"_pnlCalendar.style.display = \"none\"; } </script>");
this.Button1.Attributes.Add("OnClick","On"+this.ID+"Click()");
}
private void Calendar1_SelectionChanged(object sender,
System.EventArgs e)
{
this.TextBox1.Text = Calendar1.SelectedDate.ToShortDateString();
this.pnlCalendar.Attributes.Add("style","DISPLAY: none; POSITION:
absolute");
}