Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem using Master & Content pages with Calendar pop-up

Reply
Thread Tools

Problem using Master & Content pages with Calendar pop-up

 
 
jediknight
Guest
Posts: n/a
 
      08-28-2007
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");
}

 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      08-28-2007
What you're seeing is a JavaScript error, caused by using the ID of the
Control rather than the ClientID of the Control. The ClientID of a Control
is designed to always be unique in the client HTML document, and this is
done by using the nested position of the Control inside other Controls. The
ID is the server-side ID of the Control used for server-side processing.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"jediknight" <> wrote in message
news: ups.com...
>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");
> }
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
master pages and content pages sjsean ASP .Net 1 08-01-2009 08:40 PM
word content inside asp.net master / content pages jobs ASP .Net 1 12-13-2006 05:10 PM
Master Pages and content pages in subfolder vikramp ASP .Net 3 10-13-2006 07:07 PM
limit on number of content placeholders(which are editable in content pages) in master page nemesis.saurabh@gmail.com ASP .Net 0 05-25-2006 04:44 AM
Cross Page Post Back When Using Mixture of Master Pages and Non-Master Pages Jason@webbit.com ASP .Net 1 05-16-2006 02:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57