一个令人困惑的问题!请高手们来研究!

yohomonkey 2003-01-27 01:11:54
前不久,由于需要,作了个usercontrol,时间的自定义控件,结果出现了一个十分奇怪的问题,一直不知其所以然!困惑很久,无法解决,现向大家求教!
具体控件SelTimeFromDPL.ascx包括:一个textbox(填写年份,autopostback=true,有changed事件),两个dropdownlist(DPL_month:选择月份和DPL_day选择日期,autopostback=true,都有changed事件)。
现象是,当填写了年份,鼠标离开textbox,在页面其他地方点一下,再选择DPL_month或DPL_day,没有问题;如果填写完textbox的年份,直接点选DPL,页面会白屏(去掉textbox的autopostback就不会有问题)!但是,如果在textbox和dpl的changed事件添加断点,不会有问题。
这是ms的bug还是我的代吗有问题!欢迎大家来看看!
...全文
30 20 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
yohomonkey 2003-02-19
  • 打赏
  • 举报
回复
up
yohomonkey 2003-01-29
  • 打赏
  • 举报
回复
to 思归:
正在试.........

祝大家新年快乐!
这是我年前的最后一贴!
年后见!
xiaomaoxia 2003-01-28
  • 打赏
  • 举报
回复
hohoo
cqhz 2003-01-28
  • 打赏
  • 举报
回复
你的代码看起来好象没错诶!搞不懂是不是ms出问题了!
saucer 2003-01-27
  • 打赏
  • 举报
回复
what else on your aspx page? can you view the html source when you have 白屏? try to delete the cache (Tools->Internet Options->General, click on Delete Files button, check "Delete all offline content", click on OK, OK)
yohomonkey 2003-01-27
  • 打赏
  • 举报
回复
to 摇钱树:
控件使用脚本,会不会有通用的问题!???
但是,我们这的确是白屏,奇怪啊!
去掉textbox的auotpostback的确没有问题,但是,页面要得到textbox的value,用脚本似乎没有办法传值啊(控件到调用控件的页面)!
angel_lee 2003-01-27
  • 打赏
  • 举报
回复
study:)
WSDOTNET 2003-01-27
  • 打赏
  • 举报
回复
我将代码重现了一下,发现只要编辑textbox的内容,紧接着点击dropdownlist,首先是刷新屏幕(一闪而过,很快,没有白屏。即事件TextBox1_TextChanged发生,编辑后点击其它处亦是发生此事件,因为有AutoPostBack属性),然后再点击dropdownlist才有效。
我的建议是:去掉TextBox1的AutoPostBack属性,而在客户端脚本里写dropdownlist得到焦点(点击事件)时的数据初始化代码。
Lostinet 2003-01-27
  • 打赏
  • 举报
回复
有没有什么链接来测试一下?
yohomonkey 2003-01-27
  • 打赏
  • 举报
回复
刚刚用鼠标双击datalist,又白屏!从新进页面,再试,又好了!
这是这么一回事啊!!!!!
smartyyp 2003-01-27
  • 打赏
  • 举报
回复
我也碰到类似的问提
好想是这样的
yohomonkey 2003-01-27
  • 打赏
  • 举报
回复
我的ie版本是用vs.net更新了的,还打了ie的漏洞补丁,版本ie6。
saucer 2003-01-27
  • 打赏
  • 举报
回复
如果填写完textbox的年份,直接点选DPL, textbox's OnChange event is triggered first, which will cause the postback, but it will not affect the dropdownlist, what version of IE are you using? try to run it in separate browser instead of in VS.NET
coolman666 2003-01-27
  • 打赏
  • 举报
回复
up
yohomonkey 2003-01-27
  • 打赏
  • 举报
回复
to 思归:
如果添加断点没有问题,我这里只要去掉断点,就白屏了!
我是怀疑,ms的usercontrol的autopostback是否会对post敏感,不知到触发的是textboxchanged还是dpl的selectedchanged如我描述的,textbox的autopostback去掉,就好了!
还请大侠帮助!
saucer 2003-01-27
  • 打赏
  • 举报
回复
不能重复你的问题,把TextBox改成

<asp:TextBox id="TextBox1" runat="server" Width="49px" MaxLength="4"
AutoPostBack="true"
>1901</asp:TextBox>

后,如果填写完textbox的年份,直接点选DPL,页面没有白屏,只是页面刷新了一下,触发了textbox的事件而已

我用的是IE6 SP1
大健 2003-01-27
  • 打赏
  • 举报
回复
up
tingningpower 2003-01-27
  • 打赏
  • 举报
回复
应是MS出问题,我也搞不懂!


还是系统,

我看不懂VB
yohomonkey 2003-01-27
  • 打赏
  • 举报
回复
vb:
Public MustInherit Class SelTimeFromDPL
Inherits System.Web.UI.UserControl
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents DPL_month As System.Web.UI.WebControls.DropDownList
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents DPL_day As System.Web.UI.WebControls.DropDownList
Protected WithEvents Label3 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Public Property GetYear() As String
Get
Dim year As Integer
Try
year = CInt(TextBox1.Text)
Catch
TextBox1.Text = 1901
End Try
Return TextBox1.Text
End Get
Set(ByVal Value As String)

End Set
End Property

Public Property GetMonth() As String
Get
Return DPL_month.SelectedItem.Value
End Get
Set(ByVal Value As String)

End Set
End Property

Public Property GetDay() As String
Get
Return DPL_day.SelectedItem.Value
End Get
Set(ByVal Value As String)

End Set
End Property

Public Property Getmm_dd_yyyy() As String
Get
Return DPL_month.SelectedItem.Value & "/" & DPL_day.SelectedItem.Value & "/" & TextBox1.Text
End Get
Set(ByVal Value As String)
Dim day, month, year As String
year = Right(Value, 4)
SetYear(year)
month = Left(Value, 2)
SetMonth(month)
day = Mid(Value, 4, 2)
SetDay(day)
End Set
End Property

Public Property Enabled() As String
Get
Return Me.Session("enavled")
End Get
Set(ByVal Value As String)
Me.Session("enavled") = Value
DPL_month.Enabled = Value
DPL_day.Enabled = Value
TextBox1.Enabled = Value
End Set
End Property

Private Sub SetDay(ByVal day As String)
DPL_day.SelectedIndex = CInt(day) - 1
End Sub

Private Sub SetMonth(ByVal month As String)
DPL_month.SelectedIndex = CInt(month) - 1
CheckDay()
End Sub

Private Sub SetYear(ByVal year As String)
TextBox1.Text = year
CheckDay()
End Sub

Private Sub AddDate(ByVal num As Integer, ByRef dateColl As ListItemCollection)
Dim i As Integer
If num > 0 Then
If dateColl.Count > 0 Then dateColl.Clear()
For i = 1 To num
Dim j As String
If i < 10 Then
j = "0" & i.ToString
Else
j = i.ToString
End If
dateColl.Add(New ListItem(j, j))
Next
End If
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub DPL_month_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DPL_month.SelectedIndexChanged
CheckDay()
End Sub

Private Sub CheckDay()
DPL_day.Items.Clear()
Select Case CInt(DPL_month.SelectedItem.Value)
Case 1, 3, 5, 7, 8, 10, 12

AddDate(31, DPL_day.Items)
Case 4, 6, 9, 11
AddDate(30, DPL_day.Items)
' DPL_day.Items.FindByValue("31").Selected = False
Case 2
Dim leapyear As Integer
leapyear = CInt(TextBox1.Text)
If DateTime.IsLeapYear(leapyear) = True Then
AddDate(29, DPL_day.Items)
Else
AddDate(28, DPL_day.Items)
End If
End Select
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
CheckDay()
End Sub

End Class
yohomonkey 2003-01-27
  • 打赏
  • 举报
回复
aspx:
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="SelTimeFromDPL.ascx.vb" Inherits="OA_Project.SelTimeFromDPL" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<asp:TextBox id="TextBox1" runat="server" Width="49px" MaxLength="4">1901</asp:TextBox>
<asp:Label id="Label3" runat="server">Year</asp:Label>
<asp:DropDownList id="DPL_month" runat="server" Width="50px" AutoPostBack="True">
<asp:ListItem Value="01" Selected="True">01</asp:ListItem>
<asp:ListItem Value="02">02</asp:ListItem>
<asp:ListItem Value="03">03</asp:ListItem>
<asp:ListItem Value="04">04</asp:ListItem>
<asp:ListItem Value="05">05</asp:ListItem>
<asp:ListItem Value="06">06</asp:ListItem>
<asp:ListItem Value="07">07</asp:ListItem>
<asp:ListItem Value="08">08</asp:ListItem>
<asp:ListItem Value="09">09</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
</asp:DropDownList>
<asp:Label id="Label1" runat="server">Month</asp:Label>
<asp:DropDownList id="DPL_day" runat="server" Width="50px" DESIGNTIMEDRAGDROP="9" AutoPostBack="True">
<asp:ListItem Value="01" Selected="True">01</asp:ListItem>
<asp:ListItem Value="02">02</asp:ListItem>
<asp:ListItem Value="03">03</asp:ListItem>
<asp:ListItem Value="04">04</asp:ListItem>
<asp:ListItem Value="05">05</asp:ListItem>
<asp:ListItem Value="06">06</asp:ListItem>
<asp:ListItem Value="07">07</asp:ListItem>
<asp:ListItem Value="08">08</asp:ListItem>
<asp:ListItem Value="09">09</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="11">11</asp:ListItem>
<asp:ListItem Value="12">12</asp:ListItem>
<asp:ListItem Value="13">13</asp:ListItem>
<asp:ListItem Value="14">14</asp:ListItem>
<asp:ListItem Value="15">15</asp:ListItem>
<asp:ListItem Value="16">16</asp:ListItem>
<asp:ListItem Value="17">17</asp:ListItem>
<asp:ListItem Value="18">18</asp:ListItem>
<asp:ListItem Value="19">19</asp:ListItem>
<asp:ListItem Value="20">20</asp:ListItem>
<asp:ListItem Value="21">21</asp:ListItem>
<asp:ListItem Value="22">22</asp:ListItem>
<asp:ListItem Value="23">23</asp:ListItem>
<asp:ListItem Value="24">24</asp:ListItem>
<asp:ListItem Value="25">25</asp:ListItem>
<asp:ListItem Value="26">26</asp:ListItem>
<asp:ListItem Value="27">27</asp:ListItem>
<asp:ListItem Value="28">28</asp:ListItem>
<asp:ListItem Value="29">29</asp:ListItem>
<asp:ListItem Value="30">30</asp:ListItem>
<asp:ListItem Value="31">31</asp:ListItem>
</asp:DropDownList>
<asp:Label id="Label2" runat="server" DESIGNTIMEDRAGDROP="11">Day</asp:Label>

62,242

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧