HTMLGenericControls, ascx, and span

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top