HTMLGenericControls, ascx, and span

G

Guest

I have created a web user control containing a web calendar (among other
controls) that is shown/hidden when the user clicks an imagebutton. I've used
SPAN tags to show/hide the calendar. I need to use several instances of this
user control in my main web page. What I need how is way to give the SPAN tag
an unique identifier for each instance of the user control so I can use
client-side code to show/hide the right instance of the web calendar without
making a trip to the server and back. I'm not quite getting all the pieces in
place using the HTMLGenericControl to make this work. Any suggestions?

tia,
Sue
 
K

Ken Cox [Microsoft MVP]

Hi Sue,

How about embedding the calendar in a Panel control? That will wrap it in a
Div that you can use much like the Span.

You can calculate the ID fairly well this way. Some code below. Let us know
if this helps?

Ken
Microsoft MVP [ASP.NET]


usrcalendar.ascx

<asp:panel id="Panel1" runat="server"><asp:Calendar id="Calendar1"
runat="server"></asp:Calendar></asp:panel>

usecalendar.aspx

<form id="Form1" method="post" runat="server">
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
<P>
<uc1:usrcalendar id="Usrcalendar1" runat="server"></uc1:usrcalendar>
<uc1:usrcalendar id="Usrcalendar2" runat="server"></uc1:usrcalendar>
<uc1:usrcalendar id="Usrcalendar3" runat="server"></uc1:usrcalendar></P>
</form>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", _
"document.all.Usrcalendar2_Panel1.style.visibility=" & _
"'hidden';return false;")
End Sub
 
G

Guest

Ken, thank you - worked just fine. Never thought to use panels in lieu of
spans.

Thanks!
Sue

Ken Cox said:
Hi Sue,

How about embedding the calendar in a Panel control? That will wrap it in a
Div that you can use much like the Span.

You can calculate the ID fairly well this way. Some code below. Let us know
if this helps?

Ken
Microsoft MVP [ASP.NET]


usrcalendar.ascx

<asp:panel id="Panel1" runat="server"><asp:Calendar id="Calendar1"
runat="server"></asp:Calendar></asp:panel>

usecalendar.aspx

<form id="Form1" method="post" runat="server">
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
<P>
<uc1:usrcalendar id="Usrcalendar1" runat="server"></uc1:usrcalendar>
<uc1:usrcalendar id="Usrcalendar2" runat="server"></uc1:usrcalendar>
<uc1:usrcalendar id="Usrcalendar3" runat="server"></uc1:usrcalendar></P>
</form>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", _
"document.all.Usrcalendar2_Panel1.style.visibility=" & _
"'hidden';return false;")
End Sub

Sue said:
I have created a web user control containing a web calendar (among other
controls) that is shown/hidden when the user clicks an imagebutton. I've
used
SPAN tags to show/hide the calendar. I need to use several instances of
this
user control in my main web page. What I need how is way to give the SPAN
tag
an unique identifier for each instance of the user control so I can use
client-side code to show/hide the right instance of the web calendar
without
making a trip to the server and back. I'm not quite getting all the pieces
in
place using the HTMLGenericControl to make this work. Any suggestions?

tia,
Sue
 
K

Ken Cox [Microsoft MVP]

Glad to help!

Ken

Sue said:
Ken, thank you - worked just fine. Never thought to use panels in lieu of
spans.

Thanks!
Sue

Ken Cox said:
Hi Sue,

How about embedding the calendar in a Panel control? That will wrap it in
a
Div that you can use much like the Span.

You can calculate the ID fairly well this way. Some code below. Let us
know
if this helps?

Ken
Microsoft MVP [ASP.NET]


usrcalendar.ascx

<asp:panel id="Panel1" runat="server"><asp:Calendar id="Calendar1"
runat="server"></asp:Calendar></asp:panel>

usecalendar.aspx

<form id="Form1" method="post" runat="server">
<P>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button></P>
<P>
<uc1:usrcalendar id="Usrcalendar1" runat="server"></uc1:usrcalendar>
<uc1:usrcalendar id="Usrcalendar2" runat="server"></uc1:usrcalendar>
<uc1:usrcalendar id="Usrcalendar3"
runat="server"></uc1:usrcalendar></P>
</form>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add("onclick", _
"document.all.Usrcalendar2_Panel1.style.visibility=" & _
"'hidden';return false;")
End Sub

Sue said:
I have created a web user control containing a web calendar (among other
controls) that is shown/hidden when the user clicks an imagebutton.
I've
used
SPAN tags to show/hide the calendar. I need to use several instances of
this
user control in my main web page. What I need how is way to give the
SPAN
tag
an unique identifier for each instance of the user control so I can use
client-side code to show/hide the right instance of the web calendar
without
making a trip to the server and back. I'm not quite getting all the
pieces
in
place using the HTMLGenericControl to make this work. Any suggestions?

tia,
Sue
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top