各位大老,
在我的程序中,为了避免FormView输入数据时候更新,将FormView放在一个UpdatePanel内,
该Formview初始状态为ReadOnly,在用户点击遍编之后,进入编辑状态,
在编辑状态时,有一段JavaScript代码控制特定TextBox输入时候弹出一个日期选择,
问题在于,没有UpdatePanel时候,代码可以正确出来,但是加了UpdatePanel之后,
Formview的状态切换到编辑状态时,其页面代码仍然为ReadOnly,(也就是说,
虽然编辑框已经出现,客户端状态没有变化)。请教如何解决?
其中的Canlendar是一个开源的js日历控件,可以在www.dynarch.com/projects/calendar下载
以下为代码:<asp:UpdatePanel ID="UptPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
//此处为一个单独的TextBox,测试脚本是否能够正确运行,经测试,运行没有问题
<script type="text/javascript">
function InitCalendar()
{
Calendar.setup(
{
inputField : document.getElementById("<%=(TextBox1.FindControl("TextBox1")).ClientID%>"), // id of the input field
ifFormat : "%Y-%m-%d", // format of the input field
showsTime : false, // will display a time selector
button : "TextBox1", // trigger for the calendar (button ID)
singleClick : false, // double-click mode
step : 1 // show all years in drop-down boxes (instead of every other year as default)
}
)
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitCalendar);
</script> <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
//EditItemTemplate使用这段脚本不行,状态没有切换,请教???
<EditItemTemplate>
equipment_run_date:
<asp:TextBox ID="equipment_run_dateTextBox" runat="server" Text='<%# Bind("equipment_run_date","{0:yyyy-MM-dd}") %>'>
</asp:TextBox><br /> <script type="text/javascript">
function InitCalendar()
{
Calendar.setup(
{
inputField : document.getElementById("<%=((TextBox)FormView1.FindControl("equipment_run_dateTextBox")).ClientID%>"), // id of the input field
ifFormat : "%Y-%m-%d", // format of the input field
showsTime : false, // will display a time selector
button : "TextBox1", // trigger for the calendar (button ID)
singleClick : false, // double-click mode
step : 1 // show all years in drop-down boxes (instead of every other year as default)
}
)
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitCalendar);
</script> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="更新">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
equipment_run_date:
<asp:Label ID="equipment_run_dateLabel" runat="server" Text='<%# Bind("equipment_run_date") %>'>
</asp:Label><br />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="True" CommandName="New"
Text="新建">
</asp:LinkButton>
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="True" CommandName="Edit"
Text="编辑" OnClick="EditButton_Click">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</ItemTemplate>
<InsertItemTemplate>
equipment_run_date:
<asp:TextBox ID="equipment_run_dateTextBox" runat="server" Text='<%# Bind("equipment_run_date") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="插入">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NACConnectionString %>"
SelectCommand="SELECT [equipment_run_date] FROM [t_brch_mng]"></asp:SqlDataSource>
<br />
</ContentTemplate>
</asp:UpdatePanel>
在我的程序中,为了避免FormView输入数据时候更新,将FormView放在一个UpdatePanel内,
该Formview初始状态为ReadOnly,在用户点击遍编之后,进入编辑状态,
在编辑状态时,有一段JavaScript代码控制特定TextBox输入时候弹出一个日期选择,
问题在于,没有UpdatePanel时候,代码可以正确出来,但是加了UpdatePanel之后,
Formview的状态切换到编辑状态时,其页面代码仍然为ReadOnly,(也就是说,
虽然编辑框已经出现,客户端状态没有变化)。请教如何解决?
其中的Canlendar是一个开源的js日历控件,可以在www.dynarch.com/projects/calendar下载
以下为代码:<asp:UpdatePanel ID="UptPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
//此处为一个单独的TextBox,测试脚本是否能够正确运行,经测试,运行没有问题
<script type="text/javascript">
function InitCalendar()
{
Calendar.setup(
{
inputField : document.getElementById("<%=(TextBox1.FindControl("TextBox1")).ClientID%>"), // id of the input field
ifFormat : "%Y-%m-%d", // format of the input field
showsTime : false, // will display a time selector
button : "TextBox1", // trigger for the calendar (button ID)
singleClick : false, // double-click mode
step : 1 // show all years in drop-down boxes (instead of every other year as default)
}
)
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitCalendar);
</script> <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
//EditItemTemplate使用这段脚本不行,状态没有切换,请教???
<EditItemTemplate>
equipment_run_date:
<asp:TextBox ID="equipment_run_dateTextBox" runat="server" Text='<%# Bind("equipment_run_date","{0:yyyy-MM-dd}") %>'>
</asp:TextBox><br /> <script type="text/javascript">
function InitCalendar()
{
Calendar.setup(
{
inputField : document.getElementById("<%=((TextBox)FormView1.FindControl("equipment_run_dateTextBox")).ClientID%>"), // id of the input field
ifFormat : "%Y-%m-%d", // format of the input field
showsTime : false, // will display a time selector
button : "TextBox1", // trigger for the calendar (button ID)
singleClick : false, // double-click mode
step : 1 // show all years in drop-down boxes (instead of every other year as default)
}
)
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitCalendar);
</script> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="更新">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
equipment_run_date:
<asp:Label ID="equipment_run_dateLabel" runat="server" Text='<%# Bind("equipment_run_date") %>'>
</asp:Label><br />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="True" CommandName="New"
Text="新建">
</asp:LinkButton>
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="True" CommandName="Edit"
Text="编辑" OnClick="EditButton_Click">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</ItemTemplate>
<InsertItemTemplate>
equipment_run_date:
<asp:TextBox ID="equipment_run_dateTextBox" runat="server" Text='<%# Bind("equipment_run_date") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="插入">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NACConnectionString %>"
SelectCommand="SELECT [equipment_run_date] FROM [t_brch_mng]"></asp:SqlDataSource>
<br />
</ContentTemplate>
</asp:UpdatePanel>
为什么不用微软的日历控件!