【问题标题】:date and time control format日期和时间控制格式
【发布时间】:2010-02-01 18:20:59
【问题描述】:

我使用 Ajax 日历扩展器在 Date_Box 中显示日期,然后使用数字上下扩展器来选择时间...

这是我的代码:

<td bgcolor="#969ECD">
            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="Date_Box" runat="server" Width="85px"></asp:TextBox>&nbsp;

            <br />
             <div style="height: 4px"></div>

            &nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="txtHour" runat="server" ></asp:TextBox>
            <ajaxToolkit:NumericUpDownExtender ID="txtHour_NumericUpDownExtender" 
                runat="server" Enabled="True" Maximum="12" Minimum="1"  
                TargetControlID="txtHour" Width="70" >    
            </ajaxToolkit:NumericUpDownExtender>

            <asp:TextBox ID="txtMinute" runat="server"></asp:TextBox>
            <ajaxToolkit:NumericUpDownExtender ID="txtMinute_NumericUpDownExtender" 
                runat="server" Enabled="True" Maximum="59" Minimum="1" 
                TargetControlID="txtMinute" Width="70" >
            </ajaxToolkit:NumericUpDownExtender>

            <asp:TextBox ID="txtDayPart" runat="server"></asp:TextBox>
            <ajaxToolkit:NumericUpDownExtender ID="txtDayPart_NumericUpDownExtender" 
                runat="server" Enabled="True" RefValues="AM;PM" TargetControlID="txtDayPart"  Width="70">
            </ajaxToolkit:NumericUpDownExtender>

            <asp:Button ID="Update" runat="server"  Text="Update" 
               onclick="Update_Click1" />
            <br />
        </td>
    </tr>
</table>
</div>

     <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" 
    TargetControlID="Date_Box" PopupPosition="TopRight"  >
     </ajaxToolkit:CalendarExtender>

现在功能方面唯一的问题是,当我在文本框中写入非正常格式的内容并单击更新按钮时,它允许我接受这些值,而不应该让它写入除日期格式之外的任何其他内容.. 例如文本框中没有字母..

这我仍然可以弄清楚,使用一些异常消息......

但现在主要问题是控件的外观。数字扩展按钮太大,行格式不好,三个时间文本框之间也有很多空间......有没有办法让这个看起来整齐>>>

我该如何解决这个问题...有什么建议吗???!

这是图片链接http://www.freeimagehosting.net/image.php?05945773e0.jpg alt text

【问题讨论】:

    标签: c# asp.net ajax datetime


    【解决方案1】:

    最简单的做法是为您的数字扩展器分配一个CssClass 属性,并使用css 来解决布局问题。

    【讨论】:

    • 我不知道如何使用数字扩展按钮的 css 属性,因为它们会自动出现...谢谢
    【解决方案2】:

    您可以使用 asp:RegularExpressionValidator 来验证文本框内容: http://msdn.microsoft.com/en-us/library/eahwtc9e.aspx

    NumericUpDown 的文档指定您可以为 updown 按钮使用自定义图像: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/NumericUpDown/NumericUpDown.aspx

    【讨论】:

    • 是的,但是要获得一个类似的整齐的箭头图像,一个重叠的箭头是我无法找到的。我得到的是彼此相邻的向上向下箭头,它们会增加空间..可以帮我找到一张图片。。谢谢
    【解决方案3】:

    您可能想尝试使用 here 找到的 ajax 控件工具包中的 FilteredTextbox。 如果它们不符合某些标准,它将阻止在框中输入。 希望这可以帮助 汤姆

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-25
      • 1970-01-01
      • 1970-01-01
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多