How to generate a single sared DIV

V

Vance Kessler

I have made a calendar control using the .NET Calendar that pops up in
a DIV without having to open up a new window. I still have the code
in my ASPX page since I just finished working out the tricky bits (so
it is not a .NET webcontrol yet).

I want to convert this to a webcontrol but this control relies on a
single shared DIV in which the calendar is displayed and which I can
position as needed. I know how to register script so it is only
rendered once on a page no matter how many copies of the control may
be on the page. However, I cannot see how to easily do this with HTML
elements (namely the shared DIV). I don't really care where in the
body this is rendered as I will be using absolute positioning and it
starts hidden. I guess I could use the HttpContext.Items collection
to set some kind of a flag for that request.

Thanks,
Vance
 
J

Jacob Yang [MSFT]

Hi Vance,

I have reviewed your issue. Due to the nature of your issue I need to do
additional research to determine the best way to provide assistance. I will
contact you as soon as possible.

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jacob Yang [MSFT]

Hi Vance,

Based on your description, I am not sure the relation ship between the
shared DIV and the Calendar Control. Would you please clarify this issue
more detailedly? I certainly appreciate your time.

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
V

Vance Kessler

I have started converting this code into a WebControl and I think I know
why you cannot understand how I am going to use the Div. It is because
I don't know how I am going to do it now. I had forgotten that you
cannot output ASP WebControl commands from Render() in a WebControl
(that is I cannot output asp:Calendar).

So, I will have to use a Panel or some kind of container and dynamically
generate the calendar control. I also have an asp:DropDownList inside
what was my DIV. Otherwise I would have sub-classed the Calendar
control itself.

Now my question is how would I dynamically generate some WebControls and
HTML controls inside a container of some sort that would only be
rendered once per page? In my first attempt I tried this:


if (null == Context.Items["GC:CalendarControl"])
{
Context.Items.Add("GC:CalendarControl",
"ExistenceCheckOnly");
output.Write(s_sCalendarDiv);
output.Write(s_sScript);
}

Which of course did not work since I had Asp:Calendar in that string.

BTW, I am using C# under the 1.1 framework.

Thanks for any help you can give,
Vance Kessler
 
J

Jacob Yang [MSFT]

Hi Vance,

I am sorry if there is any misunderstanding.

I have done more research regarding the last question - "how would I
dynamically generate some WebControls and HTML controls inside a container
of some sort that would only be rendered once per page? ". My suggestion is
manually adding a place holder control with a KNOWN ID on the page. Then we
can write code to dynamically add the controls to the place holder's
controls collection.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
<MCSD>
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,567
Members
47,203
Latest member
EmmaSwank1

Latest Threads

Top