问题描述
我有轧光延长两个文本框控件和一个DropDownList如下:
i have two text box controls with calender extender and a dropdownlist as follows.
<asp:TextBox ID="txtStartDate" runat="server" ReadOnly="True"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtStartDate"
runat="server" Format="yyyy-MM-dd" />
<asp:TextBox ID="txtEndDate" runat="server" ReadOnly="True"
ontextchanged="txtEndDate_TextChanged">
</asp:TextBox>
<asp:CalendarExtender ID="txtEndDate_CalendarExtender" runat="server"
Enabled="True" TargetControlID="txtEndDate" Format="yyyy-MM-dd">
</asp:CalendarExtender>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
是我想做的事情,当用户选择在 txtEndDate
日期,我想调用一个函数来加载 DropDownList1 $ C数据$ C>,即的DataBind
DropDownList1
。
What i want to do is when user selects a date in txtEndDate
i want to call a function to load data in DropDownList1
, i.e DataBind DropDownList1
.
当我设置的AutoPostBack
的属性 txtEndDate
为真,并调用一个方法上的 txtEndDate_TextChanged
事件不会被解雇。
When i Set AutoPostBack
property of txtEndDate
to True and call a method on txtEndDate_TextChanged
the event does not get fired.
我要去哪里错了,谁能帮助。我只是想加载 DropDownList1
当用户选择在 txtEndDate
的日期。我有什么做的。
Where am i going wrong can anyone help. I just want to load DropDownList1
when user selects a date in txtEndDate
. What do i have to do.
下面是我在做了我的 aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String DB = "";
String AccountID = "";
if (Session["login"] != null && Session["db"] != null)
{
AccountID = Session["login"].ToString();
DB = Session["db"].ToString();
Label4.Text = AccountID;
}
else
{
Response.Redirect("log.aspx");
}
}
}
protected void txtEndDate_TextChanged(object sender, EventArgs e)
{
String databs = Session["db"].ToString();
Response.Write(databs);
ddlist1_crtno a = new ddlist1_crtno();
a.filldropdown1(this.DropDownList1, databs);
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
// LOG OUT***********////////////
Session.Abandon();
Response.Redirect("log.aspx");
}
}
我把ButtonClick事件相同的事件,一切工作正常。
I put the same event on ButtonClick event and everything worked fine.
推荐答案
试着删除只读=真
从文本框
控制。这可能会解决你的问题。
Try and remove the ReadOnly="true"
from the TextBox
control. This might solve your problem.
有与具有文本框
控制问题只读=真
的文本框的值每当回传发生丢失,这就是为什么该事件不触发的原因。
There is a problem with the TextBox
controls having ReadOnly="true"
that the value of the textbox is lost whenever PostBack happens and that is the reason why the event isn't firing.
编辑:这是一个已知的问题有没有解决的办法尚未文本框。有明显的解决方法吧。
It is a known issue with the textboxes which has no solution to it yet. there obviously are workarounds to it.
这篇关于问题在asp.net C#中使用自动回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!