<Javascript display property -


in form have textbox , calendr along other controls

<asp:textbox id="textbox2" runat="server"   onfocus="calopen()" asp:textbox>  <asp:calendar id="calendar1" runat="server" style="display:none;"          onselectionchanged="calendar1_selectionchanged"></asp:calendar>   <script type="text/javascript">          function calopen()         {          var cal = document.getelementbyid('<%=calendar1.clientid%>');          cal.style.display='block';          } </script>  protected void calendar1_selectionchanged(object sender, eventargs e)  {     textbox2.text = calendar1.selecteddate.tolongdatestring();     calendar1.visible = false; }   protected void imagebutton1_click(object sender, imageclickeventargs e) {     calendar1.visible = true; } 

for first time worked fine, but, 2nd time when click textbox2, is, after selecting date first time. browser throwing error"object required"

i unable know went wrong.

plz me in making code correct.

thank you.

when write calendar1.visible = false; in server-side code, doesn't render calendar @ all. therefore, there no calendar element javascript show.

instead, should make css class applies display: none calendar, , set cssclass property class on server.

for example:

<style type="text/css">     .hidden {         display: none;     } </style>  <asp:calendar id="calendar1" runat="server" cssclass="hidden"     onselectionchanged="calendar1_selectionchanged"></asp:calendar>  protected void calendar1_selectionchanged(object sender, eventargs e) {     textbox2.text = calendar1.selecteddate.tolongdatestring();     calendar1.cssclass = "hidden"; }   protected void imagebutton1_click(object sender, imageclickeventargs e) {     calendar1.cssclass = ""; } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -