2015-04-03 60 views
2

我使用下面的代碼來隱藏文本框,標籤和Dropdownlist。但是,我會如何隱藏日期選擇器?我可以在下面的代碼中爲datepicker做同樣的事嗎?使用其類型的隱藏日期選擇器

If (TypeOf ctrTexbox Is TextBox) Then 
     If isMasked Then 
      CType(ctrLabel, Label).Visible = True 
      CType(ctrTexbox, TextBox).Visible = False 
     Else 
      CType(ctrLabel, Label).Visible = False 
      CType(ctrTexbox, TextBox).Visible = True 
     End If 
    ElseIf (TypeOf ctrTexbox Is DropDownList) Then 
     If isMasked Then 
      CType(ctrLabel, Label).Visible = True 
      CType(ctrTexbox, DropDownList).Visible = False 
     Else 
      CType(ctrLabel, Label).Visible = False 
      CType(ctrTexbox, DropDownList).Visible = True 
     End If 

HTML的日期選擇

<BDP:BasicDatePicker Style="z-index: 205; left: 312px" ID="dtp" runat="server" width="250px" SelectedDate="1989-01-01" DateFormat="dd/MMM/yyyy">                     
    <TextBoxStyle CssClass="inputbox" Width="250px" /></BDP:BasicDatePicker> 
+0

在後面的代碼,'ID.visible = FALSE;' – BNN 2015-04-03 05:52:18

回答

0

當然可以,因爲BasicDatePicker也從同一WebControl類派生:

ElseIf (TypeOf ctrTexbox Is BasicFrame.WebControls.BasicDatePicker) Then 
    If isMasked Then 
     CType(ctrLabel, Label).Visible = True 
     CType(ctrTexbox, BasicFrame.WebControls.BasicDatePicker).Visible = False 
    Else 
     CType(ctrLabel, Label).Visible = False 
     CType(ctrTexbox, BasicFrame.WebControls.BasicDatePicker).Visible = True 
    End If 
+0

它的工作。謝謝 – Abdul 2015-04-03 06:49:49

相關問題