Capture selected date from asp calendar control

I am try to use the asp:calendar control within an update panel within a div
The purpose of the div is  to use a jquery function to make it visible and not visible

The jquery function works, the code behind gets the value from the control but the page does not show the value within the textbox.

    <div ID="divCalendarInv" class="CenterScreen">
        <asp:UpdatePanel ID="updPnlCalendarInv" runat="server">
            <asp:Calendar ID="CalendarInv" runat="server" Width="200px" OnSelectionChanged="CalendarInv_SelectionChanged"  BackColor="Blue" ForeColor="White"></asp:Calendar>

protected void CalendarInv_SelectionChanged(object sender, EventArgs e)
	txtInvoiceDate.Text = CalendarInv.SelectedDate.ToString("MM/dd/yyyy");
	ScriptManager.RegisterStartupScript(this.Page, GetType(),  "SetV", "SetVisibility('divCalendarInv')", true);

   function SetVisibility(ctlid)
        if ($('#' + ctlid).css('display') == 'none')
            $('#' + ctlid).show(); 
            $('#' + ctlid).hide(); 

Open in new window

Can anyone explain this behavior and how to fix it?

Thanks in advance
Charles SugdenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

let's forget javascript a bit and remove lines 12, 15 to 25.
do it work? could you see the date in txtInvoiceDate ?
we don't see txtInvoiceDate in your code
Charles SugdenAuthor Commented:
Sorry about the exclusion

                            <td><asp:Label ID="Label4" runat="server" Text="Invoice Id:" CssClass="LabelWidthRight"></asp:Label></td>
                            <td><asp:TextBox ID="txtInvoiceId" runat="server" CssClass="textentry" ViewStateMode="Enabled"></asp:TextBox></td>

Using a table within a master page
Charles SugdenAuthor Commented:
The div is necessary to hide or make the calendar appear without a page turn
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

if you remove all your stuff about visibility and ZERO javascript, do your code put the date in the textbox ?
Charles SugdenAuthor Commented:
Nice try. That doesn't work. Something has to make the div holding the calendar disappear
Originally I used a panel but I  didn't like the response going back to the server
so I changed the panel to a div and wanted to use jquery.

Now that I have removed the jquery the div needs to appear

<asp:Label ID="LabelInv" runat="server" Text="Invoice Date:" CssClass="LabelWidthRight"></asp:Label>
<asp:TextBox ID="txtInvoiceDate" runat="server" CssClass="textentry"></asp:TextBox>
<img alt="O" src="Images/Calendar-BusinessMonthView_16.png" class="BtnSpacerSmall" onclick='???'/>
Now that I have removed the jquery the div needs to appear

1 - By default the div MUST appear.
2 - ASAP you hide it with javascript or css

But again, it MUST be VISIBLE by default.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Charles SugdenAuthor Commented:
I resorted to the calendarexetender enclosed within a panel.
As explained, the panel had to be visible by default in order for this to work.
The control did not appear until the button was clicked even though the panel was initially visible.
So the solution worked.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.